[MM-28218] API hookup for updating company info and address in MM app (#15974)

Этот коммит содержится в:
Devin Binnie
2020-10-20 05:46:58 -04:00
коммит произвёл GitHub
родитель c05ee81c9f
Коммит 73a1c95137
4 изменённых файлов: 128 добавлений и 11 удалений

Просмотреть файл

@@ -5686,3 +5686,33 @@ func (c *Client4) GetSubscription() (*Subscription, *Response) {
return subscription, BuildResponse(r)
}
func (c *Client4) UpdateCloudCustomer(customerInfo *CloudCustomerInfo) (*CloudCustomer, *Response) {
customerBytes, _ := json.Marshal(customerInfo)
r, appErr := c.doApiPutBytes(c.GetCloudRoute()+"/customer", customerBytes)
if appErr != nil {
return nil, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
var customer *CloudCustomer
json.NewDecoder(r.Body).Decode(&customer)
return customer, BuildResponse(r)
}
func (c *Client4) UpdateCloudCustomerAddress(address *Address) (*CloudCustomer, *Response) {
addressBytes, _ := json.Marshal(address)
r, appErr := c.doApiPutBytes(c.GetCloudRoute()+"/customer/address", addressBytes)
if appErr != nil {
return nil, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
var customer *CloudCustomer
json.NewDecoder(r.Body).Decode(&customer)
return customer, BuildResponse(r)
}

Просмотреть файл

@@ -33,17 +33,22 @@ type ConfirmPaymentMethodRequest struct {
// Customer model represents a customer on the system.
type CloudCustomer struct {
ID string `json:"id"`
CreatorID string `json:"creator_id"`
CreateAt int64 `json:"create_at"`
Email string `json:"email"`
Name string `json:"name"`
NumEmployees int `json:"num_employees"`
ContactFirstName string `json:"contact_first_name"`
ContactLastName string `json:"contact_last_name"`
BillingAddress *Address `json:"billing_address"`
CompanyAddress *Address `json:"company_address"`
PaymentMethod *PaymentMethod `json:"payment_method"`
CloudCustomerInfo
ID string `json:"id"`
CreatorID string `json:"creator_id"`
CreateAt int64 `json:"create_at"`
BillingAddress *Address `json:"billing_address"`
CompanyAddress *Address `json:"company_address"`
PaymentMethod *PaymentMethod `json:"payment_method"`
}
// CloudCustomerInfo represents editable info of a customer.
type CloudCustomerInfo struct {
Name string `json:"name"`
Email string `json:"email"`
ContactFirstName string `json:"contact_first_name"`
ContactLastName string `json:"contact_last_name"`
NumEmployees int `json:"num_employees"`
}
// Address model represents a customer's address.