-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcustomer.go
75 lines (65 loc) · 2.33 KB
/
customer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package mundipagg
import "time"
// NewCustomer Return a New Customer
func (m mundipagg) NewCustomer(c *Customer, indepotencyKey string) (*Response, error) {
resp, err := MakePostRequest(c, m.BasicSecretAuthKey, indepotencyKey, CUSTOMERURL)
if err != nil {
return nil, err
}
return resp, nil
}
// Customer Constructing a customer
type Customer struct {
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
// Refence client code in the store
Code string `json:"code,omitempty"`
// CPF or CNPJ
Document string `json:"document,omitempty"`
// Type individual or company
Type string `json:"type,omitempty"`
Gender string `json:"gender,omitempty"`
Address *Address `json:"address,omitempty"`
Phones *Phones `json:"phones,omitempty"`
Birthday *time.Time `json:"birthday,omitempty"`
// Metadata Add some extra information
Metadata interface{} `json:"metadata,omitempty"`
}
/* CustomerTypes
1 - individual
2 - company
*/
func (c *Customer) CustomerTypes(customerType int) {
customer := map[int]string{
1: "individual",
2: "company",
}
c.Type = customer[customerType]
}
// Address Constructing a address for the customers
type Address struct {
ID string `json:"id,omitempty"`
// O atributo line_1 deverá seguir o formato: Número, Rua, Bairro - nesta ordem e separados por vírgula, em virtude do antifraude ou boleto com registro.
Line1 string `json:"line_1,omitempty"`
// O atributo line_2 poderá conter informações complementares do endereço, tais como andar, apto, sala, etc.
Line2 string `json:"line_2,omitempty"`
Zipcode string `json:"zip_code,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
Country string `json:"country,omitempty"`
Status string `json:"status,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
// Phones Struct to contain the data of the phones
type Phones struct {
HomePhone *Phone `json:"home_phone,omitempty"`
MobilePhone *Phone `json:"mobile_phone,omitempty"`
}
// Phone Data about the phone
type Phone struct {
CountryCode string `json:"country_code,omitempty"`
AreaCode string `json:"area_code,omitempty"`
Number string `json:"number,omitempty"`
}