code: func (leg *Leg) UnmarshalJSON(data []byte) error {
  	var raw jsonLeg
  	if err := json.Unmarshal(data, &raw); err != nil {
  		return err
  	}
  	createdAt, err := time.Parse(time.RFC3339, raw.CreatedAt)
  	if err != nil {
  		return fmt.Errorf("unable to parse Leg CreatedAt: %v", err)
  	}
  	updatedAt, err := time.Parse(time.RFC3339, raw.UpdatedAt)
  	if err != nil {
  		return fmt.Errorf("unable to parse Leg UpdatedAt: %v", err)
  	}
  	var answeredAt *time.Time
  	if raw.EndedAt != "" {
  		aat, err := time.Parse(time.RFC3339, raw.EndedAt)
  		if err != nil {
  			return fmt.Errorf("unable to parse Leg AnsweredAt: %v", err)
  		}
  		answeredAt = &aat
  	}
  	var endedAt *time.Time
  	if raw.EndedAt != "" {
  		eat, err := time.Parse(time.RFC3339, raw.EndedAt)
  		if err != nil {
  			return fmt.Errorf("unable to parse Leg EndedAt: %v", err)
  		}
  		endedAt = &eat
  	}
  	*leg = Leg{
  		ID:          raw.ID,
  		CallID:      raw.CallID,
  		Source:      raw.Source,
  		Destination: raw.Destination,
  		Status:      LegStatus(raw.Status),
  		Direction:   LegDirection(raw.Direction),
  		Cost:        raw.Cost,
  		Currency:    raw.Currency,
  		Duration:    time.Second * time.Duration(raw.Duration),
  		CreatedAt:   createdAt,
  		UpdatedAt:   updatedAt,
  		AnsweredAt:  answeredAt,
  		EndedAt:     endedAt,
  	}
  	return nil
  }
docs: // UnmarshalJSON implements the json.Unmarshaler interface.