minfraud.*MinFraud.Score   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 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
	}
33
}
34