| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package minfraud |
||
| 2 | |||
| 3 | // Insights executes Insights API. |
||
| 4 | func (s *MinFraud) Insights(req BaseRequest) (*InsightsResponse, error) { |
||
| 5 | resp := InsightsResponse{} |
||
| 6 | err := s.client.CallPOST("/v2.0/insights", req, &resp) |
||
| 7 | if err != nil { |
||
| 8 | return nil, err |
||
| 9 | } |
||
| 10 | return &resp, nil |
||
| 11 | } |
||
| 12 | |||
| 13 | // InsightsByIP executes Insights API with only ip address parameter. |
||
| 14 | func (s *MinFraud) InsightsByIP(ipaddr string) (*InsightsResponse, error) { |
||
| 15 | return s.Insights(BaseRequest{ |
||
| 16 | Device: &DeviceData{ |
||
| 17 | IPAddress: ipaddr, |
||
| 18 | }, |
||
| 19 | }) |
||
| 20 | } |
||
| 21 | |||
| 22 | // InsightsResponse has response from Insights API. |
||
| 23 | type InsightsResponse struct { |
||
| 24 | BaseResponse |
||
| 25 | IPAddress IPAddress `json:"ip_address"` |
||
| 26 | BillingAddress BillingAddress `json:"billing_address"` |
||
| 27 | CreditCard CreditCard `json:"credit_card"` |
||
| 28 | Device Device `json:"device"` |
||
| 29 | Email Email `json:"email"` |
||
| 30 | ShippingAddress ShippingAddress `json:"shipping_address"` |
||
| 31 | } |
||
| 32 | |||
| 33 | func (r InsightsResponse) APIResponse() APIResponse { |
||
| 34 | return APIResponse{ |
||
| 35 | BaseResponse: r.BaseResponse, |
||
| 36 | IPAddress: r.IPAddress, |
||
| 37 | BillingAddress: r.BillingAddress, |
||
| 38 | CreditCard: r.CreditCard, |
||
| 39 | Device: r.Device, |
||
| 40 | Email: r.Email, |
||
| 41 | ShippingAddress: r.ShippingAddress, |
||
| 42 | } |
||
| 44 |