This repository has been archived by the owner on Jun 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomers.go
51 lines (44 loc) · 1.79 KB
/
customers.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
package tuneuptechnology
import (
"strconv"
"time"
)
// Customer lists all properties of a customer
type Customer struct {
ID int `json:"id,omitempty"`
Firstname string `json:"firstname,omitempty"`
Lastname string `json:"lastname,omitempty"`
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
UserID int `json:"user_id,omitempty"`
Notes string `json:"notes,omitempty"`
LocationID int `json:"location_id,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
// CreateCustomer creates a customer
func (client *Client) CreateCustomer(data *Customer) map[string]interface{} {
endpoint := client.baseURL() + "/customers"
return client.makeHTTPRequest("post", endpoint, data)
}
// AllCustomers retrieves a list of customers
func (client *Client) AllCustomers() map[string]interface{} {
endpoint := client.baseURL() + "/customers"
return client.makeHTTPRequest("get", endpoint, nil)
}
// RetrieveCustomer retrieves a single customer
func (client *Client) RetrieveCustomer(id int) map[string]interface{} {
endpoint := client.baseURL() + "/customers/" + strconv.Itoa(id)
return client.makeHTTPRequest("get", endpoint, nil)
}
// UpdateCustomer updates a customer
func (client *Client) UpdateCustomer(id int, data *Customer) map[string]interface{} {
endpoint := client.baseURL() + "/customers/" + strconv.Itoa(id)
return client.makeHTTPRequest("patch", endpoint, data)
}
// DeleteCustomer deletes a customer
func (client *Client) DeleteCustomer(id int) map[string]interface{} {
endpoint := client.baseURL() + "/customers/" + strconv.Itoa(id)
return client.makeHTTPRequest("delete", endpoint, nil)
}