/
client.go
42 lines (36 loc) · 1.57 KB
/
client.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
package shippingcontact
import (
conekta "github.com/conekta/conekta-go"
)
// Create creates a new shipping contact
// For details see https://developers.conekta.com/api#shipping-contact.
func Create(custID string, p *conekta.ShippingContactParams) (*conekta.ShippingContact, error) {
sc := &conekta.ShippingContact{}
err := conekta.MakeRequest("POST", "/customers/"+custID+"/shipping_contacts", p, sc)
return sc, err
}
// Update updates a shipping contact
// For details see https://developers.conekta.com/api#update-shipping-contact
func Update(custID string, id string, p *conekta.ShippingContactParams) (*conekta.ShippingContact, error) {
sc := &conekta.ShippingContact{}
err := conekta.MakeRequest("PUT", "/customers/"+custID+"/shipping_contacts/"+id, p, sc)
return sc, err
}
// Find gets a shipping contact by id
func Find(custID, id string) (*conekta.ShippingContact, error) {
sc := &conekta.ShippingContact{}
err := conekta.MakeRequest("GET", "/customers/"+custID+"/shipping_contacts/"+id, &conekta.EmptyParams{}, sc)
return sc, err
}
// Delete deletes a shipping contact
func Delete(custID, id string) (*conekta.ShippingContact, error) {
sc := &conekta.ShippingContact{}
err := conekta.MakeRequest("DELETE", "/customers/"+custID+"/shipping_contacts/"+id, &conekta.EmptyParams{}, sc)
return sc, err
}
// All gets all shipping contacts from a customer
func All(custID string) (*conekta.ShippingContactList, error) {
scl := &conekta.ShippingContactList{}
err := conekta.MakeRequest("GET", "/customers/"+custID+"/shipping_contacts/", &conekta.EmptyParams{}, scl)
return scl, err
}