| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package minfraud |
||
| 2 | |||
| 3 | // Score executes Score API. |
||
| 4 | func (s *MinFraud) Score(req BaseRequest) (*ScoreResponse, error) { |
||
| 5 | resp := ScoreResponse{} |
||
| 6 | err := s.client.CallPOST("/v2.0/score", req, &resp) |
||
| 7 | if err != nil { |
||
| 8 | return nil, err |
||
| 9 | } |
||
| 10 | return &resp, nil |
||
| 11 | } |
||
| 12 | |||
| 13 | // ScoreByIP executes Score API with only ip address parameter. |
||
| 14 | func (s *MinFraud) ScoreByIP(ipaddr string) (*ScoreResponse, error) { |
||
| 15 | return s.Score(BaseRequest{ |
||
| 16 | Device: &DeviceData{ |
||
| 17 | IPAddress: ipaddr, |
||
| 18 | }, |
||
| 19 | }) |
||
| 20 | } |
||
| 21 | |||
| 22 | // ScoreResponse has response from Score API. |
||
| 23 | type ScoreResponse struct { |
||
| 24 | BaseResponse |
||
| 25 | IPAddress IPAddress `json:"ip_address"` |
||
| 26 | } |
||
| 27 | |||
| 28 | func (r ScoreResponse) APIResponse() APIResponse { |
||
| 29 | return APIResponse{ |
||
| 30 | BaseResponse: r.BaseResponse, |
||
| 31 | IPAddress: r.IPAddress, |
||
| 32 | } |
||
| 34 |