diff --git a/client.go b/client.go index 6df823d..4cea643 100644 --- a/client.go +++ b/client.go @@ -209,21 +209,21 @@ func fillSite(p *url.Values, site []string) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.APIVersions() +// data, status, err := client.APIVersions() // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.versions { -// log.Printf("%v\n", value) -// } +// for _, value := range data.versions { +// log.Printf("%v\n", value) +// } func (c *Client) APIVersions() (VersionResponse, int, error) { var resp VersionResponse @@ -246,21 +246,21 @@ func (c *Client) APIVersions() (VersionResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.APICredentials() +// data, status, err := client.APICredentials() // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.Scopes { -// log.Printf("%v\n", value) -// } +// for _, value := range data.Scopes { +// log.Printf("%v\n", value) +// } func (c *Client) APICredentials() (CredentialResponse, int, error) { var resp CredentialResponse @@ -283,19 +283,19 @@ func (c *Client) APICredentials() (CredentialResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.APISystemInfo() +// data, status, err := client.APISystemInfo() // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// log.Printf("%v\n", data) +// log.Printf("%v\n", data) func (c *Client) APISystemInfo() (SystemInfoResponse, int, error) { var resp SystemInfoResponse @@ -318,26 +318,26 @@ func (c *Client) APISystemInfo() (SystemInfoResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.Customers(retailcrm.CustomersRequest{ +// data, status, err := client.Customers(retailcrm.CustomersRequest{ // Filter: CustomersFilter{ // City: "Moscow", // }, // Page: 3, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.Customers { -// log.Printf("%v\n", value) -// } +// for _, value := range data.Customers { +// log.Printf("%v\n", value) +// } func (c *Client) Customers(parameters CustomersRequest) (CustomersResponse, int, error) { var resp CustomersResponse @@ -362,17 +362,17 @@ func (c *Client) Customers(parameters CustomersRequest) (CustomersResponse, int, // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CustomersCombine([]retailcrm.Customer{{ID: 1}, {ID: 2}}, Customer{ID: 3}) +// data, status, err := client.CustomersCombine([]retailcrm.Customer{{ID: 1}, {ID: 2}}, Customer{ID: 3}) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) CustomersCombine(customers []Customer, resultCustomer Customer) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -403,9 +403,9 @@ func (c *Client) CustomersCombine(customers []Customer, resultCustomer Customer) // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CustomersCombine(retailcrm.Customer{ +// data, status, err := client.CustomersCombine(retailcrm.Customer{ // FirstName: "Ivan", // LastName: "Ivanov", // Patronymic: "Ivanovich", @@ -417,13 +417,13 @@ func (c *Client) CustomersCombine(customers []Customer, resultCustomer Customer) // }, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // if data.Success == true { // fmt.Printf("%v", data.ID) @@ -458,20 +458,20 @@ func (c *Client) CustomerCreate(customer Customer, site ...string) (CustomerChan // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CustomersFixExternalIds([]retailcrm.IdentifiersPair{{ +// data, status, err := client.CustomersFixExternalIds([]retailcrm.IdentifiersPair{{ // ID: 1, // ExternalID: 12, // }}) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) CustomersFixExternalIds(customers []IdentifiersPair) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -500,25 +500,25 @@ func (c *Client) CustomersFixExternalIds(customers []IdentifiersPair) (Successfu // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CustomersHistory(retailcrm.CustomersHistoryRequest{ +// data, status, err := client.CustomersHistory(retailcrm.CustomersHistoryRequest{ // Filter: retailcrm.CustomersHistoryFilter{ // SinceID: 20, // }, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.History { -// log.Printf("%v\n", value) -// } +// for _, value := range data.History { +// log.Printf("%v\n", value) +// } func (c *Client) CustomersHistory(parameters CustomersHistoryRequest) (CustomersHistoryResponse, int, error) { var resp CustomersHistoryResponse @@ -543,26 +543,26 @@ func (c *Client) CustomersHistory(parameters CustomersHistoryRequest) (Customers // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CustomerNotes(retailcrm.NotesRequest{ +// data, status, err := client.CustomerNotes(retailcrm.NotesRequest{ // Filter: retailcrm.NotesFilter{ // CustomerIds: []int{1,2,3} -// }, +// }, // Page: 1, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.Notes { -// log.Printf("%v\n", value) -// } +// for _, value := range data.Notes { +// log.Printf("%v\n", value) +// } func (c *Client) CustomerNotes(parameters NotesRequest) (NotesResponse, int, error) { var resp NotesResponse @@ -587,9 +587,9 @@ func (c *Client) CustomerNotes(parameters NotesRequest) (NotesResponse, int, err // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CustomerNoteCreate(retailcrm.Note{ +// data, status, err := client.CustomerNoteCreate(retailcrm.Note{ // Text: "some text", // ManagerID: 12, // Customer: &retailcrm.Customer{ @@ -597,17 +597,17 @@ func (c *Client) CustomerNotes(parameters NotesRequest) (NotesResponse, int, err // }, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.ID) -// } +// if data.Success == true { +// log.Printf("%v\n", data.ID) +// } func (c *Client) CustomerNoteCreate(note Note, site ...string) (CreateResponse, int, error) { var resp CreateResponse @@ -638,16 +638,16 @@ func (c *Client) CustomerNoteCreate(note Note, site ...string) (CreateResponse, // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CustomerNoteDelete(12) -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// data, status, err := client.CustomerNoteDelete(12) +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) CustomerNoteDelete(id int) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -674,9 +674,9 @@ func (c *Client) CustomerNoteDelete(id int) (SuccessfulResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CustomersUpload([]retailcrm.Customer{ +// data, status, err := client.CustomersUpload([]retailcrm.Customer{ // { // FirstName: "Ivan", // LastName: "Ivanov", @@ -693,17 +693,17 @@ func (c *Client) CustomerNoteDelete(id int) (SuccessfulResponse, int, error) { // }, // }} // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.UploadedCustomers) -// } +// if data.Success == true { +// log.Printf("%v\n", data.UploadedCustomers) +// } func (c *Client) CustomersUpload(customers []Customer, site ...string) (CustomersUploadResponse, int, error) { var resp CustomersUploadResponse @@ -734,21 +734,21 @@ func (c *Client) CustomersUpload(customers []Customer, site ...string) (Customer // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.Customer(12, retailcrm.ByExternalID, "") +// data, status, err := client.Customer(12, retailcrm.ByExternalID, "") // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.Customer) -// } +// if data.Success == true { +// log.Printf("%v\n", data.Customer) +// } func (c *Client) Customer(id, by, site string) (CustomerResponse, int, error) { var resp CustomerResponse var context = checkBy(by) @@ -788,17 +788,17 @@ func (c *Client) Customer(id, by, site string) (CustomerResponse, int, error) { // retailcrm.ByID, // ) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.Customer) -// } +// if data.Success == true { +// log.Printf("%v\n", data.Customer) +// } func (c *Client) CustomerEdit(customer Customer, by string, site ...string) (CustomerChangeResponse, int, error) { var resp CustomerChangeResponse var uid = strconv.Itoa(customer.ID) @@ -836,26 +836,26 @@ func (c *Client) CustomerEdit(customer Customer, by string, site ...string) (Cus // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CorporateCustomers(retailcrm.CorporateCustomersRequest{ +// data, status, err := client.CorporateCustomers(retailcrm.CorporateCustomersRequest{ // Filter: CorporateCustomersFilter{ // City: "Moscow", // }, // Page: 3, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.CustomersCorporate { -// log.Printf("%v\n", value) -// } +// for _, value := range data.CustomersCorporate { +// log.Printf("%v\n", value) +// } func (c *Client) CorporateCustomers(parameters CorporateCustomersRequest) (CorporateCustomersResponse, int, error) { var resp CorporateCustomersResponse @@ -880,19 +880,19 @@ func (c *Client) CorporateCustomers(parameters CorporateCustomersRequest) (Corpo // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CorporateCustomerCreate(retailcrm.CorporateCustomer{ +// data, status, err := client.CorporateCustomerCreate(retailcrm.CorporateCustomer{ // Nickname: "Company", // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // if data.Success == true { // fmt.Printf("%v", data.ID) @@ -929,20 +929,20 @@ func (c *Client) CorporateCustomerCreate(customer CorporateCustomer, site ...str // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CorporateCustomersFixExternalIds([]retailcrm.IdentifiersPair{{ +// data, status, err := client.CorporateCustomersFixExternalIds([]retailcrm.IdentifiersPair{{ // ID: 1, // ExternalID: 12, // }}) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) CorporateCustomersFixExternalIds(customers []IdentifiersPair) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -971,25 +971,25 @@ func (c *Client) CorporateCustomersFixExternalIds(customers []IdentifiersPair) ( // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CorporateCustomersHistory(retailcrm.CorporateCustomersHistoryRequest{ +// data, status, err := client.CorporateCustomersHistory(retailcrm.CorporateCustomersHistoryRequest{ // Filter: retailcrm.CorporateCustomersHistoryFilter{ // SinceID: 20, // }, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.History { -// log.Printf("%v\n", value) -// } +// for _, value := range data.History { +// log.Printf("%v\n", value) +// } func (c *Client) CorporateCustomersHistory(parameters CorporateCustomersHistoryRequest) ( CorporateCustomersHistoryResponse, int, error, ) { @@ -1016,26 +1016,26 @@ func (c *Client) CorporateCustomersHistory(parameters CorporateCustomersHistoryR // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CorporateCustomersNotes(retailcrm.CorporateCustomersNotesRequest{ +// data, status, err := client.CorporateCustomersNotes(retailcrm.CorporateCustomersNotesRequest{ // Filter: CorporateCustomersNotesFilter{ // Text: "text", // }, // Page: 3, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.Notes { -// log.Printf("%v\n", value) -// } +// for _, value := range data.Notes { +// log.Printf("%v\n", value) +// } func (c *Client) CorporateCustomersNotes(parameters CorporateCustomersNotesRequest) ( CorporateCustomersNotesResponse, int, error, ) { @@ -1062,26 +1062,26 @@ func (c *Client) CorporateCustomersNotes(parameters CorporateCustomersNotesReque // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CorporateCustomerNoteCreate(retailcrm.CorporateCustomerNote{ -// Text: "text", -// Customer: &retailcrm.IdentifiersPair{ -// ID: 1, +// data, status, err := client.CorporateCustomerNoteCreate(retailcrm.CorporateCustomerNote{ +// Text: "text", +// Customer: &retailcrm.IdentifiersPair{ +// ID: 1, +// } +// }) +// +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } +// +// log.Fatalf("http status: %d, error: %s", status, err) // } -// }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } -// -// log.Fatalf("http status: %d, error: %s", status, err) -// } -// -// if data.Success == true { -// fmt.Printf("%v", data.ID) -// } +// if data.Success == true { +// fmt.Printf("%v", data.ID) +// } func (c *Client) CorporateCustomerNoteCreate(note CorporateCustomerNote, site ...string) (CreateResponse, int, error) { var resp CreateResponse @@ -1112,17 +1112,17 @@ func (c *Client) CorporateCustomerNoteCreate(note CorporateCustomerNote, site .. // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CorporateCustomerNoteDelete(12) +// data, status, err := client.CorporateCustomerNoteDelete(12) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) CorporateCustomerNoteDelete(id int) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -1149,9 +1149,9 @@ func (c *Client) CorporateCustomerNoteDelete(id int) (SuccessfulResponse, int, e // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CorporateCustomersUpload([]retailcrm.CorporateCustomer{ +// data, status, err := client.CorporateCustomersUpload([]retailcrm.CorporateCustomer{ // { // Nickname: "Company", // ExternalID: 1, @@ -1162,17 +1162,17 @@ func (c *Client) CorporateCustomerNoteDelete(id int) (SuccessfulResponse, int, e // }, // }} // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.UploadedCustomers) -// } +// if data.Success == true { +// log.Printf("%v\n", data.UploadedCustomers) +// } func (c *Client) CorporateCustomersUpload( customers []CorporateCustomer, site ...string, ) (CorporateCustomersUploadResponse, int, error) { @@ -1205,21 +1205,21 @@ func (c *Client) CorporateCustomersUpload( // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CorporateCustomer(12, retailcrm.ByExternalID, "") +// data, status, err := client.CorporateCustomer(12, retailcrm.ByExternalID, "") // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.CorporateCustomer) -// } +// if data.Success == true { +// log.Printf("%v\n", data.CorporateCustomer) +// } func (c *Client) CorporateCustomer(id, by, site string) (CorporateCustomerResponse, int, error) { var resp CorporateCustomerResponse var context = checkBy(by) @@ -1246,29 +1246,29 @@ func (c *Client) CorporateCustomer(id, by, site string) (CorporateCustomerRespon // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CorporateCustomerAddresses("ext-id", retailcrm.CorporateCustomerAddressesRequest{ -// Filter: v5,CorporateCustomerAddressesFilter{ -// Name: "Main Address", -// }, -// By: retailcrm.ByExternalID, -// Site: "site", -// Limit: 20, -// Page: 1, -// }) +// data, status, err := client.CorporateCustomerAddresses("ext-id", retailcrm.CorporateCustomerAddressesRequest{ +// Filter: v5,CorporateCustomerAddressesFilter{ +// Name: "Main Address", +// }, +// By: retailcrm.ByExternalID, +// Site: "site", +// Limit: 20, +// Page: 1, +// }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.Addresses) -// } +// if data.Success == true { +// log.Printf("%v\n", data.Addresses) +// } func (c *Client) CorporateCustomerAddresses( id string, parameters CorporateCustomerAddressesRequest, ) (CorporateCustomersAddressesResponse, int, error) { @@ -1296,20 +1296,20 @@ func (c *Client) CorporateCustomerAddresses( // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := c.CorporateCustomerAddressesCreate("ext-id", retailcrm.ByExternalID, retailcrm.CorporateCustomerAddress{ -// Text: "this is new address", -// Name: "New Address", -// }) +// data, status, err := c.CorporateCustomerAddressesCreate("ext-id", retailcrm.ByExternalID, retailcrm.CorporateCustomerAddress{ +// Text: "this is new address", +// Name: "New Address", +// }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // if data.Success == true { // fmt.Printf("%v", data.ID) @@ -1349,27 +1349,27 @@ func (c *Client) CorporateCustomerAddressesCreate( // // var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := c.CorporateCustomerAddressesEdit( -// "customer-ext-id", -// retailcrm.ByExternalID, -// retailcrm.ByExternalID, -// CorporateCustomerAddress{ -// ExternalID: "addr-ext-id", -// Name: "Main Address 2", -// }, -// ) +// data, status, err := c.CorporateCustomerAddressesEdit( +// "customer-ext-id", +// retailcrm.ByExternalID, +// retailcrm.ByExternalID, +// CorporateCustomerAddress{ +// ExternalID: "addr-ext-id", +// Name: "Main Address 2", +// }, +// ) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.Customer) -// } +// if data.Success == true { +// log.Printf("%v\n", data.Customer) +// } func (c *Client) CorporateCustomerAddressesEdit( customerID, customerBy, entityBy string, address CorporateCustomerAddress, site ...string, ) (CreateResponse, int, error) { @@ -1417,29 +1417,29 @@ func (c *Client) CorporateCustomerAddressesEdit( // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CorporateCustomerCompanies("ext-id", retailcrm.IdentifiersPairRequest{ -// Filter: v5,IdentifiersPairFilter{ -// Ids: []string{"1"}, -// }, -// By: retailcrm.ByExternalID, -// Site: "site", -// Limit: 20, -// Page: 1, -// }) +// data, status, err := client.CorporateCustomerCompanies("ext-id", retailcrm.IdentifiersPairRequest{ +// Filter: v5,IdentifiersPairFilter{ +// Ids: []string{"1"}, +// }, +// By: retailcrm.ByExternalID, +// Site: "site", +// Limit: 20, +// Page: 1, +// }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.Companies) -// } +// if data.Success == true { +// log.Printf("%v\n", data.Companies) +// } func (c *Client) CorporateCustomerCompanies( id string, parameters IdentifiersPairRequest, ) (CorporateCustomerCompaniesResponse, int, error) { @@ -1467,19 +1467,19 @@ func (c *Client) CorporateCustomerCompanies( // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := c.CorporateCustomerCompaniesCreate("ext-id", retailcrm.ByExternalID, retailcrm.Company{ -// Name: "Company name", -// }) +// data, status, err := c.CorporateCustomerCompaniesCreate("ext-id", retailcrm.ByExternalID, retailcrm.Company{ +// Name: "Company name", +// }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // if data.Success == true { // fmt.Printf("%v", data.ID) @@ -1519,27 +1519,27 @@ func (c *Client) CorporateCustomerCompaniesCreate( // // var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := c.CorporateCustomerCompaniesEdit( -// "customer-ext-id", -// retailcrm.ByExternalID, -// retailcrm.ByExternalID, -// Company{ -// ExternalID: "company-ext-id", -// Name: "New Company Name", -// }, -// ) +// data, status, err := c.CorporateCustomerCompaniesEdit( +// "customer-ext-id", +// retailcrm.ByExternalID, +// retailcrm.ByExternalID, +// Company{ +// ExternalID: "company-ext-id", +// Name: "New Company Name", +// }, +// ) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.ID) -// } +// if data.Success == true { +// log.Printf("%v\n", data.ID) +// } func (c *Client) CorporateCustomerCompaniesEdit( customerID, customerBy, entityBy string, company Company, site ...string, ) (CreateResponse, int, error) { @@ -1587,29 +1587,29 @@ func (c *Client) CorporateCustomerCompaniesEdit( // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CorporateCustomerContacts("ext-id", retailcrm.IdentifiersPairRequest{ -// Filter: retailcrm.IdentifiersPairFilter{ -// Ids: []string{"1"}, -// }, -// By: retailcrm.ByExternalID, -// Site: "site", -// Limit: 20, -// Page: 1, -// }) +// data, status, err := client.CorporateCustomerContacts("ext-id", retailcrm.IdentifiersPairRequest{ +// Filter: retailcrm.IdentifiersPairFilter{ +// Ids: []string{"1"}, +// }, +// By: retailcrm.ByExternalID, +// Site: "site", +// Limit: 20, +// Page: 1, +// }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.Contacts) -// } +// if data.Success == true { +// log.Printf("%v\n", data.Contacts) +// } func (c *Client) CorporateCustomerContacts( id string, parameters IdentifiersPairRequest, ) (CorporateCustomerContactsResponse, int, error) { @@ -1637,24 +1637,24 @@ func (c *Client) CorporateCustomerContacts( // // Example (customer with specified id or externalId should exist in specified site): // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := c.CorporateCustomerContactsCreate("ext-id", retailcrm.ByExternalID, retailcrm.CorporateCustomerContact{ -// IsMain: false, -// Customer: retailcrm.CorporateCustomerContactCustomer{ -// ExternalID: "external_id", -// Site: "site", -// }, -// Companies: []IdentifiersPair{}, -// }, "site") +// data, status, err := c.CorporateCustomerContactsCreate("ext-id", retailcrm.ByExternalID, retailcrm.CorporateCustomerContact{ +// IsMain: false, +// Customer: retailcrm.CorporateCustomerContactCustomer{ +// ExternalID: "external_id", +// Site: "site", +// }, +// Companies: []IdentifiersPair{}, +// }, "site") // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // if data.Success == true { // fmt.Printf("%v", data.ID) @@ -1694,24 +1694,24 @@ func (c *Client) CorporateCustomerContactsCreate( // // var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := c.CorporateCustomerContactsEdit("ext-id", retailcrm.ByExternalID, retailcrm.ByID, retailcrm.CorporateCustomerContact{ -// IsMain: false, -// Customer: retailcrm.CorporateCustomerContactCustomer{ -// ID: 2350, -// }, -// }, "site") +// data, status, err := c.CorporateCustomerContactsEdit("ext-id", retailcrm.ByExternalID, retailcrm.ByID, retailcrm.CorporateCustomerContact{ +// IsMain: false, +// Customer: retailcrm.CorporateCustomerContactCustomer{ +// ID: 2350, +// }, +// }, "site") // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.ID) -// } +// if data.Success == true { +// log.Printf("%v\n", data.ID) +// } func (c *Client) CorporateCustomerContactsEdit( customerID, customerBy, entityBy string, contact CorporateCustomerContact, site ...string, ) (CreateResponse, int, error) { @@ -1772,17 +1772,17 @@ func (c *Client) CorporateCustomerContactsEdit( // retailcrm.ByID, // ) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.Customer) -// } +// if data.Success == true { +// log.Printf("%v\n", data.Customer) +// } func (c *Client) CorporateCustomerEdit(customer CorporateCustomer, by string, site ...string) ( CustomerChangeResponse, int, error, ) { @@ -1822,31 +1822,30 @@ func (c *Client) CorporateCustomerEdit(customer CorporateCustomer, by string, si // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") -// t, _ := time.Parse("2006-01-02 15:04:05", "2012-12-12 12:12:12") +// var client = retailcrm.New("https://demo.url", "09jIJ") +// t, _ := time.Parse("2006-01-02 15:04:05", "2012-12-12 12:12:12") // -// data, status, err := client.DeliveryTracking( -// []retailcrm.DeliveryTrackingRequest{{ -// DeliveryID: "1", -// TrackNumber: "123", -// History: []retailcrm.DeliveryHistoryRecord{ -// { -// Code: "cancel", -// UpdatedAt: t.Format(time.RFC3339), +// data, status, err := client.DeliveryTracking( +// []retailcrm.DeliveryTrackingRequest{{ +// DeliveryID: "1", +// TrackNumber: "123", +// History: []retailcrm.DeliveryHistoryRecord{ +// { +// Code: "cancel", +// UpdatedAt: t.Format(time.RFC3339), +// }, // }, -// }, -// }}, -// "delivery-1", -// ) +// }}, +// "delivery-1", +// ) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } -// -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) DeliveryTracking(parameters []DeliveryTrackingRequest, subcode string) ( SuccessfulResponse, int, error, ) { @@ -1877,26 +1876,26 @@ func (c *Client) DeliveryTracking(parameters []DeliveryTrackingRequest, subcode // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.DeliveryShipments(retailcrm.DeliveryShipmentsRequest{ +// data, status, err := client.DeliveryShipments(retailcrm.DeliveryShipmentsRequest{ // Limit: 12, // Filter: retailcrm.ShipmentFilter{ // DateFrom: "2012-12-12", // }, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.DeliveryShipments { -// log.Printf("%v\n", value) -// } +// for _, value := range data.DeliveryShipments { +// log.Printf("%v\n", value) +// } func (c *Client) DeliveryShipments(parameters DeliveryShipmentsRequest) (DeliveryShipmentsResponse, int, error) { var resp DeliveryShipmentsResponse @@ -1921,7 +1920,7 @@ func (c *Client) DeliveryShipments(parameters DeliveryShipmentsRequest) (Deliver // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // // data, status, err := client.DeliveryShipmentCreate( // retailcrm.DeliveryShipment{ @@ -1935,17 +1934,17 @@ func (c *Client) DeliveryShipments(parameters DeliveryShipmentsRequest) (Deliver // "sdek", // ) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.ID) -// } +// if data.Success == true { +// log.Printf("%v\n", data.ID) +// } func (c *Client) DeliveryShipmentCreate( shipment DeliveryShipment, deliveryType string, site ...string, ) (DeliveryShipmentUpdateResponse, int, error) { @@ -1978,21 +1977,21 @@ func (c *Client) DeliveryShipmentCreate( // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.DeliveryShipment(12) +// data, status, err := client.DeliveryShipment(12) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.DeliveryShipment) -// } +// if data.Success == true { +// log.Printf("%v\n", data.DeliveryShipment) +// } func (c *Client) DeliveryShipment(id int) (DeliveryShipmentResponse, int, error) { var resp DeliveryShipmentResponse @@ -2015,23 +2014,23 @@ func (c *Client) DeliveryShipment(id int) (DeliveryShipmentResponse, int, error) // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.DeliveryShipmentEdit(retailcrm.DeliveryShipment{ +// data, status, err := client.DeliveryShipmentEdit(retailcrm.DeliveryShipment{ // ID: "12", // Time: retailcrm.DeliveryTime{ // From: "14:00", // To: "18:00", // }, -// }) +// }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) DeliveryShipmentEdit(shipment DeliveryShipment, site ...string) ( DeliveryShipmentUpdateResponse, int, error, ) { @@ -2063,21 +2062,21 @@ func (c *Client) DeliveryShipmentEdit(shipment DeliveryShipment, site ...string) // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.IntegrationModule("moysklad3") +// data, status, err := client.IntegrationModule("moysklad3") // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.IntegrationModule) -// } +// if data.Success == true { +// log.Printf("%v\n", data.IntegrationModule) +// } func (c *Client) IntegrationModule(code string) (IntegrationModuleResponse, int, error) { var resp IntegrationModuleResponse @@ -2198,21 +2197,21 @@ func (c *Client) UpdateScopes(code string, request ScopesRequired) (UpdateScopes // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.Orders(retailcrm.OrdersRequest{Filter: retailcrm.OrdersFilter{City: "Moscow"}, Page: 1}) +// data, status, err := client.Orders(retailcrm.OrdersRequest{Filter: retailcrm.OrdersFilter{City: "Moscow"}, Page: 1}) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.Orders { -// log.Printf("%v\n", value) -// } +// for _, value := range data.Orders { +// log.Printf("%v\n", value) +// } func (c *Client) Orders(parameters OrdersRequest) (OrdersResponse, int, error) { var resp OrdersResponse @@ -2237,17 +2236,17 @@ func (c *Client) Orders(parameters OrdersRequest) (OrdersResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.OrdersCombine("ours", retailcrm.Order{ID: 1}, retailcrm.Order{ID: 1}) +// data, status, err := client.OrdersCombine("ours", retailcrm.Order{ID: 1}, retailcrm.Order{ID: 1}) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) OrdersCombine(technique string, order, resultOrder Order) (OperationResponse, int, error) { var resp OperationResponse @@ -2279,9 +2278,9 @@ func (c *Client) OrdersCombine(technique string, order, resultOrder Order) (Oper // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.OrderCreate(retailcrm.Order{ +// data, status, err := client.OrderCreate(retailcrm.Order{ // FirstName: "Ivan", // LastName: "Ivanov", // Patronymic: "Ivanovich", @@ -2289,17 +2288,17 @@ func (c *Client) OrdersCombine(technique string, order, resultOrder Order) (Oper // Items: []retailcrm.OrderItem{{Offer: retailcrm.Offer{ID: 12}, Quantity: 5}}, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v\n", data.ID) -// } +// if data.Success == true { +// log.Printf("%v\n", data.ID) +// } func (c *Client) OrderCreate(order Order, site ...string) (OrderCreateResponse, int, error) { var resp OrderCreateResponse orderJSON, _ := json.Marshal(&order) @@ -2375,21 +2374,21 @@ func (c *Client) OrdersFixExternalIds(orders []IdentifiersPair) (SuccessfulRespo // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.OrdersHistory(retailcrm.OrdersHistoryRequest{Filter: retailcrm.OrdersHistoryFilter{SinceID: 20}}) +// data, status, err := client.OrdersHistory(retailcrm.OrdersHistoryRequest{Filter: retailcrm.OrdersHistoryFilter{SinceID: 20}}) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.History { -// log.Printf("%v\n", value) -// } +// for _, value := range data.History { +// log.Printf("%v\n", value) +// } func (c *Client) OrdersHistory(parameters OrdersHistoryRequest) (OrdersHistoryResponse, int, error) { var resp OrdersHistoryResponse @@ -2414,9 +2413,9 @@ func (c *Client) OrdersHistory(parameters OrdersHistoryRequest) (OrdersHistoryRe // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.OrderPaymentCreate(retailcrm.Payment{ +// data, status, err := client.OrderPaymentCreate(retailcrm.Payment{ // Order: &retailcrm.Order{ // ID: 12, // }, @@ -2424,17 +2423,17 @@ func (c *Client) OrdersHistory(parameters OrdersHistoryRequest) (OrdersHistoryRe // Type: "cash", // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // if data.Success == true { -// log.Printf("%v\n", data.ID) -// } +// log.Printf("%v\n", data.ID) +// } func (c *Client) OrderPaymentCreate(payment Payment, site ...string) (CreateResponse, int, error) { var resp CreateResponse @@ -2465,17 +2464,17 @@ func (c *Client) OrderPaymentCreate(payment Payment, site ...string) (CreateResp // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.OrderPaymentDelete(12) +// data, status, err := client.OrderPaymentDelete(12) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) OrderPaymentDelete(id int) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -2502,23 +2501,23 @@ func (c *Client) OrderPaymentDelete(id int) (SuccessfulResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.OrderPaymentEdit( -// retailcrm.Payment{ +// data, status, err := client.OrderPaymentEdit( +// retailcrm.Payment{ // ID: 12, // Amount: 500, // }, // retailcrm.ByID, // ) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) OrderPaymentEdit(payment Payment, by string, site ...string) (SuccessfulResponse, int, error) { var resp SuccessfulResponse var uid = strconv.Itoa(payment.ID) @@ -2556,20 +2555,20 @@ func (c *Client) OrderPaymentEdit(payment Payment, by string, site ...string) (S // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.OrdersStatuses(retailcrm.OrdersStatusesRequest{ +// data, status, err := client.OrdersStatuses(retailcrm.OrdersStatusesRequest{ // IDs: []int{1}, // ExternalIDs: []string{"2"}, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) OrdersStatuses(request OrdersStatusesRequest) (OrdersStatusesResponse, int, error) { var resp OrdersStatusesResponse @@ -2594,9 +2593,9 @@ func (c *Client) OrdersStatuses(request OrdersStatusesRequest) (OrdersStatusesRe // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.OrdersUpload([]retailcrm.Order{ +// data, status, err := client.OrdersUpload([]retailcrm.Order{ // { // FirstName: "Ivan", // LastName: "Ivanov", @@ -2613,17 +2612,17 @@ func (c *Client) OrdersStatuses(request OrdersStatusesRequest) (OrdersStatusesRe // } // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // if data.Success == true { -// log.Printf("%v\n", data.UploadedOrders) -// } +// log.Printf("%v\n", data.UploadedOrders) +// } func (c *Client) OrdersUpload(orders []Order, site ...string) (OrdersUploadResponse, int, error) { var resp OrdersUploadResponse @@ -2654,21 +2653,21 @@ func (c *Client) OrdersUpload(orders []Order, site ...string) (OrdersUploadRespo // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.Order(12, retailcrm.ByExternalID, "") +// data, status, err := client.Order(12, retailcrm.ByExternalID, "") // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // if data.Success == true { -// log.Printf("%v\n", data.Order) -// } +// log.Printf("%v\n", data.Order) +// } func (c *Client) Order(id, by, site string) (OrderResponse, int, error) { var resp OrderResponse var context = checkBy(by) @@ -2695,23 +2694,23 @@ func (c *Client) Order(id, by, site string) (OrderResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.OrderEdit( -// retailcrm.Order{ +// data, status, err := client.OrderEdit( +// retailcrm.Order{ // ID: 12, // Items: []retailcrm.OrderItem{{Offer: retailcrm.Offer{ID: 13}, Quantity: 6}}, // }, -// retailcrm.ByID, -// ) +// retailcrm.ByID, +// ) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) OrderEdit(order Order, by string, site ...string) (CreateResponse, int, error) { var resp CreateResponse var uid = strconv.Itoa(order.ID) @@ -2749,21 +2748,21 @@ func (c *Client) OrderEdit(order Order, by string, site ...string) (CreateRespon // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.Packs(retailcrm.PacksRequest{Filter: retailcrm.PacksFilter{OrderID: 12}}) +// data, status, err := client.Packs(retailcrm.PacksRequest{Filter: retailcrm.PacksFilter{OrderID: 12}}) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // for _, value := range data.Packs { -// log.Printf("%v\n", value) -// } +// log.Printf("%v\n", value) +// } func (c *Client) Packs(parameters PacksRequest) (PacksResponse, int, error) { var resp PacksResponse @@ -2788,25 +2787,25 @@ func (c *Client) Packs(parameters PacksRequest) (PacksResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.PackCreate(Pack{ +// data, status, err := client.PackCreate(Pack{ // Store: "store-1", // ItemID: 12, // Quantity: 1, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // if data.Success == true { -// log.Printf("%v\n", data.ID) -// } +// log.Printf("%v\n", data.ID) +// } func (c *Client) PackCreate(pack Pack) (CreateResponse, int, error) { var resp CreateResponse packJSON, _ := json.Marshal(&pack) @@ -2834,21 +2833,21 @@ func (c *Client) PackCreate(pack Pack) (CreateResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.PacksHistory(retailcrm.PacksHistoryRequest{Filter: retailcrm.OrdersHistoryFilter{SinceID: 5}}) +// data, status, err := client.PacksHistory(retailcrm.PacksHistoryRequest{Filter: retailcrm.OrdersHistoryFilter{SinceID: 5}}) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // for _, value := range data.History { -// log.Printf("%v\n", value) -// } +// log.Printf("%v\n", value) +// } func (c *Client) PacksHistory(parameters PacksHistoryRequest) (PacksHistoryResponse, int, error) { var resp PacksHistoryResponse @@ -2873,21 +2872,21 @@ func (c *Client) PacksHistory(parameters PacksHistoryRequest) (PacksHistoryRespo // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.Pack(112) +// data, status, err := client.Pack(112) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // if data.Success == true { -// log.Printf("%v\n", data.Pack) -// } +// log.Printf("%v\n", data.Pack) +// } func (c *Client) Pack(id int) (PackResponse, int, error) { var resp PackResponse @@ -2910,17 +2909,17 @@ func (c *Client) Pack(id int) (PackResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.PackDelete(112) +// data, status, err := client.PackDelete(112) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) PackDelete(id int) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -2943,17 +2942,17 @@ func (c *Client) PackDelete(id int) (SuccessfulResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.PackEdit(Pack{ID: 12, Quantity: 2}) +// data, status, err := client.PackEdit(Pack{ID: 12, Quantity: 2}) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) PackEdit(pack Pack) (CreateResponse, int, error) { var resp CreateResponse @@ -3020,20 +3019,20 @@ func (c *Client) CostGroups() (CostGroupsResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CostGroupEdit(retailcrm.CostGroup{ +// data, status, err := client.CostGroupEdit(retailcrm.CostGroup{ // Code: "group-1", // Color: "#da5c98", // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) CostGroupEdit(costGroup CostGroup) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -3081,20 +3080,20 @@ func (c *Client) CostItems() (CostItemsResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CostItemEdit(retailcrm.CostItem{ +// data, status, err := client.CostItemEdit(retailcrm.CostItem{ // Code: "seo", // Active: false, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) CostItemEdit(costItem CostItem) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -3142,26 +3141,26 @@ func (c *Client) Couriers() (CouriersResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CostItemEdit(retailcrm.Courier{ +// data, status, err := client.CostItemEdit(retailcrm.Courier{ // Active: true, // Email: "courier1@example.com", // FirstName: "Ivan", // LastName: "Ivanov", // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// if data.Success == true { -// log.Printf("%v", data.ID) -// } +// if data.Success == true { +// log.Printf("%v", data.ID) +// } func (c *Client) CourierCreate(courier Courier) (CreateResponse, int, error) { var resp CreateResponse @@ -3190,20 +3189,20 @@ func (c *Client) CourierCreate(courier Courier) (CreateResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.CostItemEdit(retailcrm.Courier{ +// data, status, err := client.CostItemEdit(retailcrm.Courier{ // ID: 1, // Patronymic: "Ivanovich", // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) CourierEdit(courier Courier) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -3251,20 +3250,20 @@ func (c *Client) DeliveryServices() (DeliveryServiceResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.DeliveryServiceEdit(retailcrm.DeliveryService{ +// data, status, err := client.DeliveryServiceEdit(retailcrm.DeliveryService{ // Active: false, // Code: "delivery-1", // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) DeliveryServiceEdit(deliveryService DeliveryService) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -3312,22 +3311,22 @@ func (c *Client) DeliveryTypes() (DeliveryTypesResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.DeliveryTypeEdit(retailcrm.DeliveryType{ +// data, status, err := client.DeliveryTypeEdit(retailcrm.DeliveryType{ // Active: false, // Code: "type-1", // DefaultCost: 300, // DefaultForCrm: false, // } // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) DeliveryTypeEdit(deliveryType DeliveryType) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -3375,20 +3374,20 @@ func (c *Client) LegalEntities() (LegalEntitiesResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.LegalEntityEdit(retailcrm.LegalEntity{ +// data, status, err := client.LegalEntityEdit(retailcrm.LegalEntity{ // Code: "legal-entity-1", // CertificateDate: "2012-12-12", // } // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) LegalEntityEdit(legalEntity LegalEntity) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -3436,21 +3435,21 @@ func (c *Client) OrderMethods() (OrderMethodsResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.OrderMethodEdit(retailcrm.OrderMethod{ +// data, status, err := client.OrderMethodEdit(retailcrm.OrderMethod{ // Code: "method-1", // Active: false, // DefaultForCRM: false, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) OrderMethodEdit(orderMethod OrderMethod) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -3498,21 +3497,21 @@ func (c *Client) OrderTypes() (OrderTypesResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.OrderTypeEdit(retailcrm.OrderType{ +// data, status, err := client.OrderTypeEdit(retailcrm.OrderType{ // Code: "order-type-1", // Active: false, // DefaultForCRM: false, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) OrderTypeEdit(orderType OrderType) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -3990,21 +3989,21 @@ func (c *Client) Settings() (SettingsResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.Inventories(retailcrm.InventoriesRequest{Filter: retailcrm.InventoriesFilter{Details: 1, ProductActive: 1}, Page: 1}) +// data, status, err := client.Inventories(retailcrm.InventoriesRequest{Filter: retailcrm.InventoriesFilter{Details: 1, ProductActive: 1}, Page: 1}) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // for _, value := range data.Offers { -// log.Printf("%v\n", value) -// } +// log.Printf("%v\n", value) +// } func (c *Client) Inventories(parameters InventoriesRequest) (InventoriesResponse, int, error) { var resp InventoriesResponse @@ -4143,25 +4142,25 @@ func (c *Client) PricesUpload(prices []OfferPriceUpload) (StoreUploadResponse, i // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.ProductsGroup(retailcrm.ProductsGroupsRequest{ +// data, status, err := client.ProductsGroup(retailcrm.ProductsGroupsRequest{ // Filter: retailcrm.ProductsGroupsFilter{ // Active: 1, // }, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // for _, value := range data.ProductGroup { -// log.Printf("%v\n", value) -// } +// log.Printf("%v\n", value) +// } func (c *Client) ProductsGroup(parameters ProductsGroupsRequest) (ProductsGroupsResponse, int, error) { var resp ProductsGroupsResponse @@ -4186,26 +4185,26 @@ func (c *Client) ProductsGroup(parameters ProductsGroupsRequest) (ProductsGroups // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.Products(retailcrm.ProductsRequest{ +// data, status, err := client.Products(retailcrm.ProductsRequest{ // Filter: retailcrm.ProductsFilter{ // Active: 1, // MinPrice: 1000, // }, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // for _, value := range data.Products { -// log.Printf("%v\n", value) -// } +// log.Printf("%v\n", value) +// } func (c *Client) Products(parameters ProductsRequest) (ProductsResponse, int, error) { var resp ProductsResponse @@ -4230,25 +4229,25 @@ func (c *Client) Products(parameters ProductsRequest) (ProductsResponse, int, er // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.ProductsProperties(retailcrm.ProductsPropertiesRequest{ +// data, status, err := client.ProductsProperties(retailcrm.ProductsPropertiesRequest{ // Filter: retailcrm.ProductsPropertiesFilter{ // Sites: []string["store"], // }, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // for _, value := range data.Properties { -// log.Printf("%v\n", value) -// } +// log.Printf("%v\n", value) +// } func (c *Client) ProductsProperties(parameters ProductsPropertiesRequest) (ProductsPropertiesResponse, int, error) { var resp ProductsPropertiesResponse @@ -4273,25 +4272,25 @@ func (c *Client) ProductsProperties(parameters ProductsPropertiesRequest) (Produ // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.Tasks(retailcrm.TasksRequest{ +// data, status, err := client.Tasks(retailcrm.TasksRequest{ // Filter: TasksFilter{ // DateFrom: "2012-12-12", // }, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // for _, value := range data.Tasks { -// log.Printf("%v\n", value) -// } +// log.Printf("%v\n", value) +// } func (c *Client) Tasks(parameters TasksRequest) (TasksResponse, int, error) { var resp TasksResponse @@ -4316,24 +4315,24 @@ func (c *Client) Tasks(parameters TasksRequest) (TasksResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.Tasks(retailcrm.Task{ +// data, status, err := client.Tasks(retailcrm.Task{ // Text: "task №1", // PerformerID: 12, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // if data.Success == true { -// log.Printf("%v\n", data.ID) -// } +// log.Printf("%v\n", data.ID) +// } func (c *Client) TaskCreate(task Task, site ...string) (CreateResponse, int, error) { var resp CreateResponse taskJSON, _ := json.Marshal(&task) @@ -4363,21 +4362,21 @@ func (c *Client) TaskCreate(task Task, site ...string) (CreateResponse, int, err // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.Task(12) +// data, status, err := client.Task(12) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // if data.Success == true { -// log.Printf("%v\n", data.Task) -// } +// log.Printf("%v\n", data.Task) +// } func (c *Client) Task(id int) (TaskResponse, int, error) { var resp TaskResponse @@ -4400,20 +4399,20 @@ func (c *Client) Task(id int) (TaskResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.Task(retailcrm.Task{ +// data, status, err := client.Task(retailcrm.Task{ // ID: 12 // Text: "task №2", // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) TaskEdit(task Task, site ...string) (SuccessfulResponse, int, error) { var resp SuccessfulResponse var uid = strconv.Itoa(task.ID) @@ -4450,21 +4449,21 @@ func (c *Client) TaskEdit(task Task, site ...string) (SuccessfulResponse, int, e // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.UserGroups(retailcrm.UserGroupsRequest{Page: 1}) +// data, status, err := client.UserGroups(retailcrm.UserGroupsRequest{Page: 1}) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // for _, value := range data.Groups { -// log.Printf("%v\n", value) -// } +// log.Printf("%v\n", value) +// } func (c *Client) UserGroups(parameters UserGroupsRequest) (UserGroupsResponse, int, error) { var resp UserGroupsResponse @@ -4489,21 +4488,21 @@ func (c *Client) UserGroups(parameters UserGroupsRequest) (UserGroupsResponse, i // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.Users(retailcrm.UsersRequest{Filter: retailcrm.UsersFilter{Active: 1}, Page: 1}) +// data, status, err := client.Users(retailcrm.UsersRequest{Filter: retailcrm.UsersFilter{Active: 1}, Page: 1}) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // for _, value := range data.Users { -// log.Printf("%v\n", value) -// } +// log.Printf("%v\n", value) +// } func (c *Client) Users(parameters UsersRequest) (UsersResponse, int, error) { var resp UsersResponse @@ -4528,21 +4527,21 @@ func (c *Client) Users(parameters UsersRequest) (UsersResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.User(12) +// data, status, err := client.User(12) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // if data.Success == true { -// log.Printf("%v\n", data.User) -// } +// log.Printf("%v\n", data.User) +// } func (c *Client) User(id int) (UserResponse, int, error) { var resp UserResponse @@ -4565,17 +4564,17 @@ func (c *Client) User(id int) (UserResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.UserStatus(12, "busy") +// data, status, err := client.UserStatus(12, "busy") // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) UserStatus(id int, status string) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -4625,7 +4624,7 @@ func (c *Client) StaticticsUpdate() (SuccessfulResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // // data, status, err := client.Costs(CostsRequest{ // Filter: CostsFilter{ @@ -4634,17 +4633,17 @@ func (c *Client) StaticticsUpdate() (SuccessfulResponse, int, error) { // }, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.Costs { -// log.Printf("%v\n", value.Summ) -// } +// for _, value := range data.Costs { +// log.Printf("%v\n", value.Summ) +// } func (c *Client) Costs(costs CostsRequest) (CostsResponse, int, error) { var resp CostsResponse @@ -4670,33 +4669,33 @@ func (c *Client) Costs(costs CostsRequest) (CostsResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // // data, status, err := client.CostCreate( -// retailcrm.CostRecord{ +// retailcrm.CostRecord{ // DateFrom: "2012-12-12", // DateTo: "2012-12-12", // Summ: 12, // CostItem: "calculation-of-costs", // Order: Order{ -// Number: "1" -// }, -// Sites: []string{"store"}, +// Number: "1" +// }, +// Sites: []string{"store"}, // }, // "store" -// ) +// ) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// If data.Success == true { -// log.Printf("%v", data.ID) -// } +// If data.Success == true { +// log.Printf("%v", data.ID) +// } func (c *Client) CostCreate(cost CostRecord, site ...string) (CreateResponse, int, error) { var resp CreateResponse @@ -4727,21 +4726,21 @@ func (c *Client) CostCreate(cost CostRecord, site ...string) (CreateResponse, in // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // // data, status, err := client.client.CostsDelete([]int{1, 2, 3, 48, 49, 50}) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// If data.Success == true { -// log.Printf("Not removed costs: %v", data.NotRemovedIds) -// } +// If data.Success == true { +// log.Printf("Not removed costs: %v", data.NotRemovedIds) +// } func (c *Client) CostsDelete(ids []int) (CostsDeleteResponse, int, error) { var resp CostsDeleteResponse @@ -4770,7 +4769,7 @@ func (c *Client) CostsDelete(ids []int) (CostsDeleteResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // // data, status, err := client.CostCreate([]retailcrm.CostRecord{ // { @@ -4779,9 +4778,9 @@ func (c *Client) CostsDelete(ids []int) (CostsDeleteResponse, int, error) { // Summ: 12, // CostItem: "calculation-of-costs", // Order: Order{ -// Number: "1" -// }, -// Sites: []string{"store"}, +// Number: "1" +// }, +// Sites: []string{"store"}, // }, // { // DateFrom: "2012-12-13", @@ -4789,19 +4788,19 @@ func (c *Client) CostsDelete(ids []int) (CostsDeleteResponse, int, error) { // Summ: 13, // CostItem: "seo", // } -// }) +// }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// If data.Success == true { -// log.Printf("Uploaded costs: %v", data.UploadedCosts) -// } +// If data.Success == true { +// log.Printf("Uploaded costs: %v", data.UploadedCosts) +// } func (c *Client) CostsUpload(cost []CostRecord) (CostsUploadResponse, int, error) { var resp CostsUploadResponse @@ -4830,21 +4829,21 @@ func (c *Client) CostsUpload(cost []CostRecord) (CostsUploadResponse, int, error // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // // data, status, err := client.Cost(1) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// If data.Success == true { -// log.Printf("%v", data.Cost) -// } +// If data.Success == true { +// log.Printf("%v", data.Cost) +// } func (c *Client) Cost(id int) (CostResponse, int, error) { var resp CostResponse @@ -4868,17 +4867,17 @@ func (c *Client) Cost(id int) (CostResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // // data, status, err := client.CostDelete(1) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) CostDelete(id int) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -4908,7 +4907,7 @@ func (c *Client) CostDelete(id int) (SuccessfulResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // // data, status, err := client.CostEdit(1, retailcrm.Cost{ // DateFrom: "2012-12-12", @@ -4917,17 +4916,17 @@ func (c *Client) CostDelete(id int) (SuccessfulResponse, int, error) { // CostItem: "seo", // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// If data.Success == true { -// log.Printf("%v", data.ID) -// } +// If data.Success == true { +// log.Printf("%v", data.ID) +// } func (c *Client) CostEdit(id int, cost CostRecord, site ...string) (CreateResponse, int, error) { var resp CreateResponse @@ -4958,7 +4957,7 @@ func (c *Client) CostEdit(id int, cost CostRecord, site ...string) (CreateRespon // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // // data, status, err := client.Files(FilesRequest{ // Filter: FilesFilter{ @@ -4966,13 +4965,13 @@ func (c *Client) CostEdit(id int, cost CostRecord, site ...string) (CreateRespon // }, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } func (c *Client) Files(files FilesRequest) (FilesResponse, int, error) { var resp FilesResponse @@ -4998,22 +4997,22 @@ func (c *Client) Files(files FilesRequest) (FilesResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// file, err := os.Open("file.jpg") -// if err != nil { -// fmt.Print(err) -// } +// file, err := os.Open("file.jpg") +// if err != nil { +// fmt.Print(err) +// } // -// data, status, err := client.FileUpload(file) +// data, status, err := client.FileUpload(file) // -// if err.Error() != "" { -// fmt.Printf("%v", err.Error()) -// } +// if err.Error() != "" { +// fmt.Printf("%v", err.Error()) +// } // -// if status >= http.StatusBadRequest { -// fmt.Printf("%v", err.Error()) -// } +// if status >= http.StatusBadRequest { +// fmt.Printf("%v", err.Error()) +// } func (c *Client) FileUpload(reader io.Reader) (FileUploadResponse, int, error) { var resp FileUploadResponse @@ -5037,21 +5036,21 @@ func (c *Client) FileUpload(reader io.Reader) (FileUploadResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.File(112) +// data, status, err := client.File(112) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // // if data.Success == true { -// log.Printf("%v\n", data.File) -// } +// log.Printf("%v\n", data.File) +// } func (c *Client) File(id int) (FileResponse, int, error) { var resp FileResponse @@ -5074,17 +5073,17 @@ func (c *Client) File(id int) (FileResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.FileDelete(123) +// data, status, err := client.FileDelete(123) // -// if err.Error() != "" { -// fmt.Printf("%v", err.Error()) -// } +// if err.Error() != "" { +// fmt.Printf("%v", err.Error()) +// } // -// if status >= http.StatusBadRequest { -// fmt.Printf("%v", err.Error()) -// } +// if status >= http.StatusBadRequest { +// fmt.Printf("%v", err.Error()) +// } func (c *Client) FileDelete(id int) (SuccessfulResponse, int, error) { var resp SuccessfulResponse @@ -5108,17 +5107,17 @@ func (c *Client) FileDelete(id int) (SuccessfulResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// fileData, status, err := client.FileDownload(123) +// fileData, status, err := client.FileDownload(123) // -// if err.Error() != "" { -// fmt.Printf("%v", err.Error()) -// } +// if err.Error() != "" { +// fmt.Printf("%v", err.Error()) +// } // -// if status >= http.StatusBadRequest { -// fmt.Printf("%v", err.Error()) -// } +// if status >= http.StatusBadRequest { +// fmt.Printf("%v", err.Error()) +// } func (c *Client) FileDownload(id int) (io.ReadCloser, int, error) { data, status, err := c.GetRequest(fmt.Sprintf("/files/%d/download", id)) if status != http.StatusOK { @@ -5135,17 +5134,17 @@ func (c *Client) FileDownload(id int) (io.ReadCloser, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.FileEdit(123, File{Filename: "image2.jpg"}) +// data, status, err := client.FileEdit(123, File{Filename: "image2.jpg"}) // -// if err.Error() != "" { -// fmt.Printf("%v", err.Error()) -// } +// if err.Error() != "" { +// fmt.Printf("%v", err.Error()) +// } // -// if status >= http.StatusBadRequest { -// fmt.Printf("%v", err.Error()) -// } +// if status >= http.StatusBadRequest { +// fmt.Printf("%v", err.Error()) +// } func (c *Client) FileEdit(id int, file File) (FileResponse, int, error) { var resp FileResponse @@ -5174,22 +5173,22 @@ func (c *Client) FileEdit(id int, file File) (FileResponse, int, error) { // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // // data, status, err := client.CustomFields(retailcrm.CustomFieldsRequest{ // Type: "string", -// Entity: "customer", +// Entity: "customer", // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.CustomFields { +// for _, value := range data.CustomFields { // fmt.Printf("%v\n", value) // } func (c *Client) CustomFields(customFields CustomFieldsRequest) (CustomFieldsResponse, int, error) { @@ -5320,21 +5319,21 @@ func (c *Client) CustomDictionariesCreate(customDictionary CustomDictionary) (Cu // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // // data, status, err := client.CustomDictionary("courier-profiles") // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// If data.Success == true { -// log.Printf("%v", data.CustomDictionary.Name) -// } +// If data.Success == true { +// log.Printf("%v", data.CustomDictionary.Name) +// } func (c *Client) CustomDictionary(code string) (CustomDictionaryResponse, int, error) { var resp CustomDictionaryResponse @@ -5414,7 +5413,7 @@ func (c *Client) CustomDictionaryEdit(customDictionary CustomDictionary) (Custom // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // // data, status, err := client.CustomFieldsCreate(CustomFields{ // Name: "First order", @@ -5424,17 +5423,17 @@ func (c *Client) CustomDictionaryEdit(customDictionary CustomDictionary) (Custom // DisplayArea: "customer", // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// If data.Success == true { -// log.Printf("%v", data.Code) -// } +// If data.Success == true { +// log.Printf("%v", data.Code) +// } func (c *Client) CustomFieldsCreate(customFields CustomFields) (CustomResponse, int, error) { var resp CustomResponse @@ -5464,21 +5463,21 @@ func (c *Client) CustomFieldsCreate(customFields CustomFields) (CustomResponse, // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // // data, status, err := client.CustomField("order", "first-order") // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// If data.Success == true { -// log.Printf("%v", data.CustomField) -// } +// If data.Success == true { +// log.Printf("%v", data.CustomField) +// } func (c *Client) CustomField(entity, code string) (CustomFieldResponse, int, error) { var resp CustomFieldResponse @@ -5502,7 +5501,7 @@ func (c *Client) CustomField(entity, code string) (CustomFieldResponse, int, err // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // // data, status, err := client.CustomFieldEdit(CustomFields{ // Code: "first-order", @@ -5510,17 +5509,17 @@ func (c *Client) CustomField(entity, code string) (CustomFieldResponse, int, err // DisplayArea: "delivery", // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// If data.Success == true { -// log.Printf("%v", data.Code) -// } +// If data.Success == true { +// log.Printf("%v", data.Code) +// } func (c *Client) CustomFieldEdit(customFields CustomFields) (CustomResponse, int, error) { var resp CustomResponse @@ -5552,9 +5551,9 @@ func (c *Client) CustomFieldEdit(customFields CustomFields) (CustomResponse, int // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.BonusOperations(retailcrm.BonusOperationsRequest{ +// data, status, err := client.BonusOperations(retailcrm.BonusOperationsRequest{ // Filter: BonusOperationsFilter{ // LoyaltyId: []int{123, 456}, // }, @@ -5562,17 +5561,17 @@ func (c *Client) CustomFieldEdit(customFields CustomFields) (CustomResponse, int // Cursor: "123456", // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.BonusOperations { -// log.Printf("%v\n", value) -// } +// for _, value := range data.BonusOperations { +// log.Printf("%v\n", value) +// } func (c *Client) BonusOperations(parameters BonusOperationsRequest) (BonusOperationsResponse, int, error) { var resp BonusOperationsResponse @@ -5597,9 +5596,9 @@ func (c *Client) BonusOperations(parameters BonusOperationsRequest) (BonusOperat // // Example: // -// var client = retailcrm.New("https://demo.url", "09jIJ") +// var client = retailcrm.New("https://demo.url", "09jIJ") // -// data, status, err := client.AccountBonusOperations(retailcrm.AccountBonusOperationsRequest{ +// data, status, err := client.AccountBonusOperations(retailcrm.AccountBonusOperationsRequest{ // Filter: AccountBonusOperationsFilter{ // CreatedAtFrom: "2012-12-12", // CreatedAtTo: "2012-12-13", @@ -5608,17 +5607,17 @@ func (c *Client) BonusOperations(parameters BonusOperationsRequest) (BonusOperat // Page: 3, // }) // -// if err != nil { -// if apiErr, ok := retailcrm.AsAPIError(err); ok { -// log.Fatalf("http status: %d, %s", status, apiErr.String()) -// } +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } // -// log.Fatalf("http status: %d, error: %s", status, err) -// } +// log.Fatalf("http status: %d, error: %s", status, err) +// } // -// for _, value := range data.BonusOperations { -// log.Printf("%v\n", value) -// } +// for _, value := range data.BonusOperations { +// log.Printf("%v\n", value) +// } func (c *Client) AccountBonusOperations(id int, parameters AccountBonusOperationsRequest) (BonusOperationsResponse, int, error) { var resp BonusOperationsResponse @@ -5644,6 +5643,40 @@ func (c *Client) AccountBonusOperations(id int, parameters AccountBonusOperation return resp, status, nil } +// ProductsBatchEdit perform editing products batch +// +// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-store-products-batch-edit +// +// Example: +// +// var client = retailcrm.New("https://demo.url", "09jIJ") +// +// products := []ProductEdit{{ +// CatalogID: 3, +// BaseProduct: BaseProduct{ +// Name: "Product 1", +// URL: "https://example.com/p/1", +// Article: "p1", +// ExternalID: "ext1", +// }, +// ID: 194, +// Site: "second", +// Groups: []ProductEditGroupInput{{ID: 19}}, +// }} +// +// data, status, err := client.ProductsBatchEdit(products) +// +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } +// +// log.Fatalf("http status: %d, error: %s", status, err) +// } +// +// if data.Success == true { +// log.Printf("%v", data.ProcessedProductsCount) +// } func (c *Client) ProductsBatchEdit(products []ProductEdit) (ProductsBatchEditResponse, int, error) { var resp ProductsBatchEditResponse @@ -5666,6 +5699,38 @@ func (c *Client) ProductsBatchEdit(products []ProductEdit) (ProductsBatchEditRes return resp, status, nil } +// ProductsBatchCreate perform adding products batch +// +// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-store-products-batch-create +// +// Example: +// +// var client = retailcrm.New("https://demo.url", "09jIJ") +// +// products := []ProductCreate{{ +// CatalogID: 3, +// BaseProduct: BaseProduct{ +// Name: "Product 1", +// URL: "https://example.com/p/1", +// Article: "p1", +// ExternalID: "ext1", +// }, +// Groups: []ProductEditGroupInput{{ID: 19}}, +// }} +// +// data, status, err := client.ProductsBatchCreate(products) +// +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } +// +// log.Fatalf("http status: %d, error: %s", status, err) +// } +// +// if data.Success == true { +// log.Printf("%v", data.AddedProducts) +// } func (c *Client) ProductsBatchCreate(products []ProductCreate) (ProductsBatchEditResponse, int, error) { var resp ProductsBatchEditResponse @@ -5688,3 +5753,280 @@ func (c *Client) ProductsBatchCreate(products []ProductCreate) (ProductsBatchEdi return resp, status, nil } +// LoyaltyAccountCreate аdd a client to the loyalty program +// +// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-loyalty-account-create +// +// Example: +// +// var client = retailcrm.New("https://demo.url", "09jIJ") +// acc := SerializedCreateLoyaltyAccount{ +// SerializedBaseLoyaltyAccount: SerializedBaseLoyaltyAccount{ +// PhoneNumber: "89151005004", +// CustomFields: []string{"dog"}, +// }, +// Customer: SerializedEntityCustomer{ +// ID: 123, +// }, +// } +// +// data, status, err := client.LoyaltyAccountCreate("site", acc) +// +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } +// +// log.Fatalf("http status: %d, error: %s", status, err) +// } +// +// if data.Success == true { +// log.Printf("%v", data.LoyaltyAccount.ID) +// } +func (c *Client) LoyaltyAccountCreate(site string, loyaltyAccount SerializedCreateLoyaltyAccount) (CreateLoyaltyAccountResponse, int, error) { + var result CreateLoyaltyAccountResponse + + loyaltyAccountJSON, _ := json.Marshal(loyaltyAccount) + p := url.Values{ + "site": {site}, + "loyaltyAccount": {string(loyaltyAccountJSON)}, + } + + resp, status, err := c.PostRequest("/loyalty/account/create", p) + + if err != nil { + return result, status, err + } + + err = json.Unmarshal(resp, &result) + + if err != nil { + return result, status, err + } + + return result, status, nil +} + +// LoyaltyAccountEdit edit a client in the loyalty program +// +// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-loyalty-account-id-edit +// +// Example: +// +// var client = retailcrm.New("https://demo.url", "09jIJ") +// acc := SerializedEditLoyaltyAccount{ +// SerializedBaseLoyaltyAccount: SerializedBaseLoyaltyAccount{ +// PhoneNumber: "89151005004", +// CustomFields: []string{"dog"}, +// }, +// } +// +// data, status, err := client.LoyaltyAccountEdit(13, acc) +// +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } +// +// log.Fatalf("http status: %d, error: %s", status, err) +// } +// +// if data.Success == true { +// log.Printf("%v", data.LoyaltyAccount.PhoneNumber) +// } +func (c *Client) LoyaltyAccountEdit(ID int, loyaltyAccount SerializedEditLoyaltyAccount) (EditLoyaltyAccountResponse, int, error) { + var result EditLoyaltyAccountResponse + + loyaltyAccountJSON, _ := json.Marshal(loyaltyAccount) + p := url.Values{ + "loyaltyAccount": {string(loyaltyAccountJSON)}, + } + + resp, status, err := c.PostRequest(fmt.Sprintf("/loyalty/account/%d/edit", ID), p) + + if err != nil { + return result, status, err + } + + err = json.Unmarshal(resp, &result) + + if err != nil { + return result, status, err + } + + return result, status, nil +} + +// LoyaltyAccount return information about client in the loyalty program +// +// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#get--api-v5-loyalty-account-id +// +// Example: +// +// var client = retailcrm.New("https://demo.url", "09jIJ") +// +// data, status, err := client.LoyaltyAccount(13) +// +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } +// +// log.Fatalf("http status: %d, error: %s", status, err) +// } +// +// if data.Success == true { +// log.Printf("%v", data.LoyaltyAccount.PhoneNumber) +// } +func (c *Client) LoyaltyAccount(ID int) (LoyaltyAccountResponse, int, error) { + var result LoyaltyAccountResponse + + resp, status, err := c.GetRequest(fmt.Sprintf("/loyalty/account/%d", ID)) + + if err != nil { + return result, status, err + } + + err = json.Unmarshal(resp, &result) + + if err != nil { + return result, status, err + } + + return result, status, nil +} + +// LoyaltyAccountActivate activate participation in the loyalty program for client +// +// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-loyalty-account-id-activate +// +// Example: +// +// var client = retailcrm.New("https://demo.url", "09jIJ") +// +// data, status, err := client.LoyaltyAccountActivate(13) +// +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } +// +// log.Fatalf("http status: %d, error: %s", status, err) +// } +// +// if data.Success == true { +// log.Printf("%v", data.LoyaltyAccount.Active) +// } +func (c *Client) LoyaltyAccountActivate(ID int) (LoyaltyAccountActivateResponse, int, error) { + var result LoyaltyAccountActivateResponse + + resp, status, err := c.PostRequest(fmt.Sprintf("/loyalty/account/%d/activate", ID), strings.NewReader("")) + + if err != nil { + return result, status, err + } + + err = json.Unmarshal(resp, &result) + + if err != nil { + return result, status, err + } + + return result, status, nil +} + +// LoyaltyBonusCredit accrue bonus participation in the program of loyalty +// +// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-loyalty-account-id-bonus-credit +// +// Example: +// +// var client = retailcrm.New("https://demo.url", "09jIJ") +// +// req := LoyaltyBonusCreditRequest{ +// Amount: 120, +// ExpiredDate: "2023-11-24 12:39:37", +// Comment: "Test", +// } +// +// data, status, err := client.LoyaltyBonusCredit(13, req) +// +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } +// +// log.Fatalf("http status: %d, error: %s", status, err) +// } +// +// if data.Success == true { +// log.Printf("%v", data.LoyaltyBonus.ActivationDate) +// } +func (c *Client) LoyaltyBonusCredit(ID int, req LoyaltyBonusCreditRequest) (LoyaltyBonusCreditResponse, int, error) { + var result LoyaltyBonusCreditResponse + p, _ := query.Values(req) + + resp, status, err := c.PostRequest(fmt.Sprintf("/loyalty/account/%d/bonus/credit", ID), p) + + if err != nil { + return result, status, err + } + + err = json.Unmarshal(resp, &result) + + if err != nil { + return result, status, err + } + + return result, status, nil +} + +// LoyaltyBonusStatusDetails get details on the bonus account +// +// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#get--api-v5-loyalty-account-id-bonus-status-details +// +// Example: +// +// var client = retailcrm.New("https://demo.url", "09jIJ") +// +// req := LoyaltyBonusStatusDetailsRequest{ +// Limit: 20, +// Page: 3, +// } +// +// data, status, err := client.LoyaltyBonusStatusDetails(13, "waiting_activation", req) +// +// if err != nil { +// if apiErr, ok := retailcrm.AsAPIError(err); ok { +// log.Fatalf("http status: %d, %s", status, apiErr.String()) +// } +// +// log.Fatalf("http status: %d, error: %s", status, err) +// } +// +// if data.Success == true { +// for _, bonus := range data.Bonuses { +// log.Printf("%v", bonus.Amount) +// } +// } +func (c *Client) LoyaltyBonusStatusDetails( + ID int, statusType string, request LoyaltyBonusStatusDetailsRequest, +) (LoyaltyBonusDetailsResponse, int, error) { + var result LoyaltyBonusDetailsResponse + + p, _ := query.Values(request) + + resp, status, err := c.GetRequest(fmt.Sprintf("/loyalty/account/%d/bonus/%s/details?%s", ID, statusType, p.Encode())) + + if err != nil { + return result, status, err + } + + err = json.Unmarshal(resp, &result) + + if err != nil { + return result, status, err + } + + return result, status, nil +} diff --git a/client_test.go b/client_test.go index 23b9ab6..009c015 100644 --- a/client_test.go +++ b/client_test.go @@ -3,6 +3,7 @@ package retailcrm import ( "encoding/json" "fmt" + "github.com/google/go-querystring/query" "io/ioutil" "log" "math/rand" @@ -21,6 +22,8 @@ import ( gock "gopkg.in/h2non/gock.v1" ) +const prefix = "/api/v5" + func TestMain(m *testing.M) { err := godotenv.Load(".env") if err != nil { @@ -5124,6 +5127,26 @@ func TestClient_IntegrationModule(t *testing.T) { BaseURL: fmt.Sprintf("http://example.com/%s", name), ClientID: RandomString(10), Logo: "https://cdn.worldvectorlogo.com/logos/github-icon.svg", + Integrations: &Integrations{ + Delivery: &Delivery{ + StatusList: []DeliveryStatus{ + { + Code: "st1", + Name: "st1", + IsEditable: true, + IsError: true, + IsPreprocessing: false, + }, + { + Code: "st2", + Name: "st2", + IsEditable: false, + IsError: false, + IsPreprocessing: false, + }, + }, + }, + }, } jsonData := fmt.Sprintf( @@ -5140,7 +5163,24 @@ func TestClient_IntegrationModule(t *testing.T) { MatchType("url"). BodyString(pr.Encode()). Reply(201). - BodyString(`{"success": true}`) + BodyString(`{ + "success": true, + "info": { + "deliveryType": { + "id": 38, + "code": "sdek-v-2-podkliuchenie-1" + }, + "billingInfo": { + "price": 0, + "currency": { + "name": "Рубль", + "shortName": "руб.", + "code": "RUB" + }, + "billingType": "fixed" + } + } + }`) m, status, err := c.IntegrationModuleEdit(integrationModule) if err != nil { @@ -6803,25 +6843,144 @@ func TestClient_AccountBonusOperations_Fail(t *testing.T) { } } -// TODO Проверить реально запросы func TestClient_ProductsBatchCreate(t *testing.T) { defer gock.Off() products := getProductsCreate() - productsJSON, err := json.Marshal(getProductsCreate()) + productsJSON, err := json.Marshal(products) assert.NoError(t, err) p := url.Values{"products": {string(productsJSON)}} gock.New(crmURL). - Post("/store/products/batch/create"). + Post(prefix + "/store/products/batch/create"). BodyString(p.Encode()). Reply(http.StatusOK). JSON(getProductsCreateResponse()) + resp, status, err := client().ProductsBatchCreate(products) + + if err != nil { + t.Errorf("%v", err) + } + + if !statuses[status] { + t.Errorf("%v", err) + } + + if resp.Success != true || resp.ProcessedProductsCount == 0 { + t.Errorf("%v", err) + } +} + +func TestClient_ProductsBatchCreateFail(t *testing.T) { + defer gock.Off() + + products := getProductsCreate() + productsJSON, err := json.Marshal(products) + assert.NoError(t, err) + + p := url.Values{"products": {string(productsJSON)}} + + gock.New(crmURL). + Post(prefix + "/store/products/batch/create"). + BodyString(p.Encode()). + Reply(http.StatusBadRequest). + JSON(`{"success":false,"errorMsg":"Something went wrong"}`) resp, status, err := client().ProductsBatchCreate(products) + if err == nil { + t.Error("Expected error") + } + + if status < http.StatusBadRequest { + t.Errorf("%v", err) + } + + if resp.Success != false { + t.Error(successFail) + } +} + +func TestClient_ProductsBatchEdit(t *testing.T) { + defer gock.Off() + + products := getProductsEdit() + productsJSON, err := json.Marshal(products) + assert.NoError(t, err) + + p := url.Values{"products": {string(productsJSON)}} + + gock.New(crmURL). + Post(prefix + "/store/products/batch/edit"). + BodyString(p.Encode()). + Reply(http.StatusOK). + JSON(getProductsEditResponse()) + + resp, status, err := client().ProductsBatchEdit(products) + + if err != nil { + t.Errorf("%v", err) + } + + if !statuses[status] { + t.Errorf("%v", err) + } + + if resp.Success != true || resp.ProcessedProductsCount == 0 { + t.Errorf("%v", err) + } +} + +func TestClient_ProductsBatchEditFail(t *testing.T) { + defer gock.Off() + + products := getProductsEdit() + productsJSON, err := json.Marshal(products) + assert.NoError(t, err) + + p := url.Values{"products": {string(productsJSON)}} + + gock.New(crmURL). + Post(prefix + "/store/products/batch/edit"). + BodyString(p.Encode()). + Reply(http.StatusInternalServerError). + JSON(`{"success":false,"errorMsg":"Something went wrong"}`) + + resp, status, err := client().ProductsBatchEdit(products) + + if err == nil { + t.Error("Expected error") + } + + if status != http.StatusInternalServerError { + t.Errorf("%v", err) + } + + if resp.Success != false { + t.Error(successFail) + } +} + +func TestClient_LoyaltyAccountCreate(t *testing.T) { + defer gock.Off() + + acc := getLoyaltyAccountCreate() + accJSON, _ := json.Marshal(acc) + p := url.Values{ + "site": {"second"}, + "loyaltyAccount": {string(accJSON)}, + } + + gock.New(crmURL). + Post(prefix + "/loyalty/account/create"). + BodyString(p.Encode()). + Reply(http.StatusOK). + JSON(getLoyaltyAccountCreateResponse()) + + resp, status, err := client().LoyaltyAccountCreate("second", acc) + if err != nil { t.Errorf("%v", err) } @@ -6834,3 +6993,280 @@ func TestClient_ProductsBatchCreate(t *testing.T) { t.Errorf("%v", err) } } + +func TestClient_LoyaltyAccountCreateFail(t *testing.T) { + defer gock.Off() + + acc := getLoyaltyAccountCreate() + accJSON, _ := json.Marshal(acc) + p := url.Values{ + "site": {"second"}, + "loyaltyAccount": {string(accJSON)}, + } + + gock.New(crmURL). + Post("/loyalty/account/create"). + BodyString(p.Encode()). + Reply(http.StatusInternalServerError). + JSON(`{"success":false,"errorMsg":"Something went wrong"}`) + + resp, status, err := client().LoyaltyAccountCreate("second", acc) + + if err == nil { + t.Error("Expected error") + } + + if status != http.StatusInternalServerError { + t.Errorf("%v", err) + } + + if resp.Success != false { + t.Error(successFail) + } +} + +func TestClient_LoyaltyAccountEdit(t *testing.T) { + defer gock.Off() + + acc := getLoyaltyAccountCreate() + acc.PhoneNumber = "89142221020" + req := SerializedEditLoyaltyAccount{acc.SerializedBaseLoyaltyAccount} + reqJSON, _ := json.Marshal(req) + p := url.Values{ + "loyaltyAccount": {string(reqJSON)}, + } + + gock.New(crmURL). + Post(fmt.Sprintf("/loyalty/account/%d/edit", 13)). + BodyString(p.Encode()). + Reply(http.StatusOK). + JSON(getLoyaltyAccountEditResponse()) + + res, status, err := client().LoyaltyAccountEdit(13, req) + + if err != nil { + t.Errorf("%v", err) + } + + if !statuses[status] { + t.Errorf("%v", err) + } + + if res.Success != true { + t.Errorf("%v", err) + } +} + +func TestClient_LoyaltyAccountEditFail(t *testing.T) { + defer gock.Off() + + acc := getLoyaltyAccountCreate() + acc.PhoneNumber = "89142221020" + req := SerializedEditLoyaltyAccount{acc.SerializedBaseLoyaltyAccount} + reqJSON, _ := json.Marshal(req) + p := url.Values{ + "loyaltyAccount": {string(reqJSON)}, + } + + gock.New(crmURL). + Post(fmt.Sprintf("/loyalty/account/%d/edit", 13)). + BodyString(p.Encode()). + Reply(http.StatusInternalServerError). + JSON(`{"success":false,"errorMsg":"Something went wrong"}`) + + res, status, err := client().LoyaltyAccountEdit(13, req) + + if err == nil { + t.Error("Expected error") + } + + if status != http.StatusInternalServerError { + t.Errorf("%v", err) + } + + if res.Success != false { + t.Error(successFail) + } +} + +func TestClient_LoyaltyAccount(t *testing.T) { + defer gock.Off() + + gock.New(crmURL). + Get(prefix + fmt.Sprintf("/loyalty/account/%d", 13)). + Reply(http.StatusOK). + JSON(getLoyaltyAccountResponse()) + + res, status, err := client().LoyaltyAccount(13) + + if err != nil { + t.Errorf("%v", err) + } + + if !statuses[status] { + t.Errorf("%v", err) + } + + if res.Success != true { + t.Errorf("%v", err) + } + + assert.NotEmpty(t, res.LoyaltyAccount.ID) + assert.NotEmpty(t, res.LoyaltyAccount.Loyalty) + assert.NotEmpty(t, res.LoyaltyAccount.Customer) + assert.NotEmpty(t, res.LoyaltyAccount.PhoneNumber) + assert.NotEmpty(t, res.LoyaltyAccount.NextLevelSum) + assert.NotEmpty(t, res.LoyaltyAccount.LoyaltyLevel) + assert.NotEmpty(t, res.LoyaltyAccount.CreatedAt) + assert.NotEmpty(t, res.LoyaltyAccount.ActivatedAt) + assert.NotEmpty(t, res.LoyaltyAccount.Status) +} + +func TestClient_LoyaltyAccountActivate(t *testing.T) { + defer gock.Off() + + var resp LoyaltyAccountActivateResponse + err := json.Unmarshal([]byte(getLoyaltyAccountResponse()), &resp) + assert.NoError(t, err) + resp.Verification = SmsVerification{ + CreatedAt: "2022-11-24 12:39:37", + ExpiredAt: "2022-11-24 12:39:37", + VerifiedAt: "2022-11-24 13:39:37", + CheckID: "test", + ActionType: "test", + } + gock.New(crmURL). + Post(prefix + fmt.Sprintf("/loyalty/account/%d/activate", 13)). + Body(strings.NewReader("")). + Reply(http.StatusOK). + JSON(resp) + + res, status, err := client().LoyaltyAccountActivate(13) + + if err != nil { + t.Errorf("%v", err) + } + + if !statuses[status] { + t.Errorf("%v", err) + } + + if res.Success != true { + t.Errorf("%v", err) + } + + assert.NotEmpty(t, res.LoyaltyAccount.ID) + assert.NotEmpty(t, res.LoyaltyAccount.Loyalty) + assert.NotEmpty(t, res.LoyaltyAccount.Customer) + assert.NotEmpty(t, res.LoyaltyAccount.PhoneNumber) + assert.NotEmpty(t, res.LoyaltyAccount.NextLevelSum) + assert.NotEmpty(t, res.LoyaltyAccount.LoyaltyLevel) + assert.NotEmpty(t, res.LoyaltyAccount.CreatedAt) + assert.NotEmpty(t, res.LoyaltyAccount.ActivatedAt) + assert.NotEmpty(t, res.LoyaltyAccount.Status) + assert.NotEmpty(t, res.Verification) +} + +func TestClient_LoyaltyBonusCredit(t *testing.T) { + defer gock.Off() + + req := LoyaltyBonusCreditRequest{ + Amount: 120, + ExpiredDate: "2023-11-24 12:39:37", + Comment: "Test", + } + body, err := query.Values(req) + assert.NoError(t, err) + + gock.New(crmURL). + Post(prefix + fmt.Sprintf("/loyalty/account/%d/bonus/credit", 13)). + BodyString(body.Encode()). + Reply(http.StatusOK). + JSON(`{ + "success":true, + "loyaltyBonus": { + "amount":120, + "expiredDate":"2023-11-24 12:39:37" + } + }`) + + res, status, err := client().LoyaltyBonusCredit(13, req) + + if err != nil { + t.Errorf("%v", err) + } + + if !statuses[status] { + t.Errorf("%v", err) + } + + if res.Success != true { + t.Errorf("%v", err) + } +} + +func TestClient_LoyaltyBonusCreditFail(t *testing.T) { + defer gock.Off() + + req := LoyaltyBonusCreditRequest{ + Amount: 120, + ExpiredDate: "2023-11-24 12:39:37", + Comment: "Test", + } + body, err := query.Values(req) + assert.NoError(t, err) + + gock.New(crmURL). + Post(prefix + fmt.Sprintf("/loyalty/account/%d/bonus/credit", 13)). + BodyString(body.Encode()). + Reply(http.StatusInternalServerError). + JSON(`{"success":false,"errorMsg":"Something went wrong"}`) + + res, status, err := client().LoyaltyBonusCredit(13, req) + + if err == nil { + t.Error("Expected error") + } + + if status != http.StatusInternalServerError { + t.Errorf("%v", err) + } + + if res.Success != false { + t.Error(successFail) + } +} + +func TestClient_LoyaltyBonusStatusDetails(t *testing.T) { + defer gock.Off() + + req := LoyaltyBonusStatusDetailsRequest{ + Limit: 20, + Page: 3, + } + + gock.New(crmURL). + Get(prefix+fmt.Sprintf("/loyalty/account/%d/bonus/%s/details", 13, "waiting_activation")). + MatchParam("limit", strconv.Itoa(20)). + MatchParam("page", strconv.Itoa(3)). + Reply(http.StatusOK). + JSON(getBonusDetailsResponse()) + + res, status, err := client().LoyaltyBonusStatusDetails(13, "waiting_activation", req) + + if err != nil { + t.Errorf("%v", err) + } + + if !statuses[status] { + t.Errorf("%v", err) + } + + if res.Success != true { + t.Errorf("%v", err) + } + + assert.NotEmpty(t, res.Pagination.TotalCount) + assert.NotEmpty(t, res.Bonuses) + assert.NotEmpty(t, res.Statistic.TotalAmount) +} diff --git a/request.go b/request.go index 21df512..c034188 100644 --- a/request.go +++ b/request.go @@ -246,6 +246,19 @@ type AccountBonusOperationsRequest struct { Page int `url:"page,omitempty"` } +type LoyaltyBonusCreditRequest struct { + Amount float64 `url:"amount"` + ActivationDate string `url:"activationDate,omitempty"` + ExpiredDate string `url:"expiredDate,omitempty"` + Comment string `url:"comment,omitempty"` +} + +type LoyaltyBonusStatusDetailsRequest struct { + Limit int `url:"limit,omitempty"` + Page int `url:"page,omitempty"` + Filter LoyaltyBonusApiFilterType `url:"filter,omitempty"` +} + // SystemURL returns system URL from the connection request without trailing slash. func (r ConnectRequest) SystemURL() string { if r.URL == "" { diff --git a/response.go b/response.go index 878f8ee..e6ffb6c 100644 --- a/response.go +++ b/response.go @@ -5,6 +5,17 @@ type SuccessfulResponse struct { Success bool `json:"success"` } +type CreateLoyaltyAccountResponse struct { + SuccessfulResponse + LoyaltyAccount LoyaltyAccount `json:"loyaltyAccount,omitempty"` + Warnings []string `json:"warnings,omitempty"` +} + +type EditLoyaltyAccountResponse struct { + SuccessfulResponse + LoyaltyAccount LoyaltyAccount `json:"loyaltyAccount,omitempty"` +} + // CreateResponse type. type CreateResponse struct { Success bool `json:"success"` @@ -376,13 +387,13 @@ type ProductEditNotFoundResponse struct { } type ProductsBatchEditResponse struct { - Success bool `json:"success"` + SuccessfulResponse ProcessedProductsCount int `json:"processedProductsCount,omitempty"` NotFoundProducts []ProductEditNotFoundResponse `json:"notFoundProducts,omitempty"` } type ProductsBatchCreateResponse struct { - Success bool `json:"success"` + SuccessfulResponse ProcessedProductsCount int `json:"processedProductsCount,omitempty"` AddedProducts []int `json:"addedProducts,omitempty"` } @@ -434,9 +445,10 @@ type IntegrationModuleEditResponse struct { // ResponseInfo type. type ResponseInfo struct { - MgTransportInfo MgInfo `json:"mgTransport,omitempty"` - MgBotInfo MgInfo `json:"mgBot,omitempty"` - BillingInfo *BillingInfo `json:"billingInfo,omitempty"` + MgTransportInfo MgInfo `json:"mgTransport,omitempty"` + MgBotInfo MgInfo `json:"mgBot,omitempty"` + BillingInfo *BillingInfo `json:"billingInfo,omitempty"` + DeliveryTypeInfo DeliveryTypeInfo `json:"deliveryType,omitempty"` } type BillingInfo struct { @@ -581,3 +593,35 @@ type AccountBonusOperationsResponse struct { Pagination *Pagination `json:"pagination,omitempty"` BonusOperations []BonusOperation `json:"bonusOperations,omitempty"` } + +type LoyaltyAccountResponse struct { + SuccessfulResponse + LoyaltyAccount `json:"loyaltyAccount"` +} + +type LoyaltyAccountActivateResponse struct { + SuccessfulResponse + LoyaltyAccount `json:"loyaltyAccount"` + Verification SmsVerification `json:"verification,omitempty"` +} + +type LoyaltyBonusCreditResponse struct { + SuccessfulResponse + LoyaltyBonus LoyaltyBonus `json:"loyaltyBonus"` +} + +type LoyaltyBonusDetailsResponse struct { + SuccessfulResponse + Pagination `json:"pagination"` + Statistic LoyaltyBonusStatisticResponse `json:"statistic"` + Bonuses []BonusDetail `json:"bonuses"` +} + +type LoyaltyBonusStatisticResponse struct { + TotalAmount float64 `json:"totalAmount"` +} + +type BonusDetail struct { + Date string `json:"date"` + Amount float64 `json:"amount"` +} diff --git a/testutils.go b/testutils.go index cb06737..cc22c53 100644 --- a/testutils.go +++ b/testutils.go @@ -6,7 +6,7 @@ package retailcrm func getProductsCreate() []ProductCreate { products := []ProductCreate{ { - CatalogID: 123, + CatalogID: 3, BaseProduct: BaseProduct{ Name: "Product 1", URL: "https://example.com/p/1", @@ -19,12 +19,12 @@ func getProductsCreate() []ProductCreate { Novelty: true, Recommended: true, Active: true, - Groups: []ProductGroup{{ID: 333}}, Markable: true, }, + Groups: []ProductEditGroupInput{{ID: 19}}, }, { - CatalogID: 123, + CatalogID: 3, BaseProduct: BaseProduct{ Name: "Product 2", URL: "https://example.com/p/2", @@ -37,9 +37,9 @@ func getProductsCreate() []ProductCreate { Novelty: true, Recommended: true, Active: true, - Groups: []ProductGroup{{ID: 444}}, Markable: true, }, + Groups: []ProductEditGroupInput{{ID: 19}}, }, } @@ -48,8 +48,134 @@ func getProductsCreate() []ProductCreate { func getProductsCreateResponse() ProductsBatchCreateResponse { return ProductsBatchCreateResponse{ - Success: true, + SuccessfulResponse: SuccessfulResponse{Success: true}, ProcessedProductsCount: 2, - AddedProducts: []int{1, 2}, + AddedProducts: []int{1, 2}, } } + +func getProductsEdit() []ProductEdit { + products := []ProductEdit{ + { + BaseProduct: getProductsCreate()[0].BaseProduct, + ID: 194, + CatalogID: 3, + Site: "second", + }, + { + BaseProduct: getProductsCreate()[1].BaseProduct, + ID: 195, + CatalogID: 3, + Site: "second", + }, + } + + return products +} + +func getProductsEditResponse() ProductsBatchEditResponse { + return ProductsBatchEditResponse{ + SuccessfulResponse: SuccessfulResponse{Success: true}, + ProcessedProductsCount: 2, + NotFoundProducts: nil, + } +} + +func getLoyaltyAccountCreate() SerializedCreateLoyaltyAccount { + return SerializedCreateLoyaltyAccount{ + SerializedBaseLoyaltyAccount: SerializedBaseLoyaltyAccount{ + PhoneNumber: "89151005004", + CustomFields: []string{"dog"}, + }, + Customer: SerializedEntityCustomer{ + ID: 123, + }, + } +} + +func getLoyaltyAccountCreateResponse() CreateLoyaltyAccountResponse { + return CreateLoyaltyAccountResponse{ + SuccessfulResponse: SuccessfulResponse{Success: true}, + LoyaltyAccount: LoyaltyAccount{ + Active: true, + ID: 13, + PhoneNumber: "89151005004", + LoyaltyLevel: LoyaltyLevel{}, + CreatedAt: "2022-11-24 12:39:37", + ActivatedAt: "2022-11-24 12:39:37", + CustomFields: []string{"dog"}, + }, + } +} + +func getLoyaltyAccountEditResponse() EditLoyaltyAccountResponse { + return EditLoyaltyAccountResponse{ + SuccessfulResponse: SuccessfulResponse{Success: true}, + LoyaltyAccount: LoyaltyAccount{ + Active: true, + ID: 13, + PhoneNumber: "89142221020", + LoyaltyLevel: LoyaltyLevel{}, + CreatedAt: "2022-11-24 12:39:37", + ActivatedAt: "2022-11-24 12:39:37", + CustomFields: []string{"dog"}, + }, + } +} + +func getLoyaltyAccountResponse() string { + return `{ + "success": true, + "loyaltyAccount": { + "active": true, + "id": 13, + "loyalty": { + "id": 2 + }, + "customer": { + "id": 123, + "customFields": [], + "firstName": "Руслан1", + "lastName": "Ефанов", + "patronymic": "" + }, + "phoneNumber": "89142221020", + "amount": 0, + "ordersSum": 0, + "nextLevelSum": 10000, + "level": { + "type": "bonus_percent", + "id": 5, + "name": "Новичок", + "sum": 0, + "privilegeSize": 5, + "privilegeSizePromo": 3 + }, + "createdAt": "2022-11-24 12:39:37", + "activatedAt": "2022-11-24 12:39:37", + "status": "activated", + "customFields": [] + } + }` +} + +func getBonusDetailsResponse() string { + return `{ + "success": true, + "pagination": { + "limit": 20, + "totalCount": 41, + "currentPage": 3, + "totalPageCount": 3 + }, + "statistic": { + "totalAmount": 240 + }, + "bonuses": [ + { + "date": "2022-12-08", + "amount": 240 + } + ] + }` +} diff --git a/types.go b/types.go index 90fe8cc..68fc16c 100644 --- a/types.go +++ b/types.go @@ -703,6 +703,21 @@ type WorkTime struct { LunchEndTime string `json:"lunch_end_time"` } +type SerializedBaseLoyaltyAccount struct { + PhoneNumber string `json:"phoneNumber,omitempty"` + CardNumber string `json:"cardNumber,omitempty"` + CustomFields []string `json:"customFields,omitempty"` +} + +type SerializedCreateLoyaltyAccount struct { + SerializedBaseLoyaltyAccount + Customer SerializedEntityCustomer `json:"customer"` +} + +type SerializedEditLoyaltyAccount struct { + SerializedBaseLoyaltyAccount +} + // Settings type. Contains retailCRM configuration. type Settings struct { DefaultCurrency SettingsNode `json:"default_currency"` @@ -793,6 +808,11 @@ type LegalEntity struct { BankAccount string `json:"bankAccount,omitempty"` } +type SerializedEntityCustomer struct { + ID int `json:"id,omitempty"` + ExternalID int `json:"externalId,omitempty"` +} + // OrderMethod type. type OrderMethod struct { Name string `json:"name,omitempty"` @@ -926,45 +946,53 @@ type ProductGroup struct { // BaseProduct type. type BaseProduct struct { - Name string `json:"name,omitempty"` - URL string `json:"url,omitempty"` - Article string `json:"article,omitempty"` - ExternalID string `json:"externalId,omitempty"` - Manufacturer string `json:"manufacturer,omitempty"` - Description string `json:"description,omitempty"` - Popular bool `json:"popular,omitempty"` - Stock bool `json:"stock,omitempty"` - Novelty bool `json:"novelty,omitempty"` - Recommended bool `json:"recommended,omitempty"` - Active bool `json:"active,omitempty"` - Groups []ProductGroup `json:"groups,omitempty"` - Markable bool `json:"markable,omitempty"` + Name string `json:"name,omitempty"` + URL string `json:"url,omitempty"` + Article string `json:"article,omitempty"` + ExternalID string `json:"externalId,omitempty"` + Manufacturer string `json:"manufacturer,omitempty"` + Description string `json:"description,omitempty"` + Popular bool `json:"popular,omitempty"` + Stock bool `json:"stock,omitempty"` + Novelty bool `json:"novelty,omitempty"` + Recommended bool `json:"recommended,omitempty"` + Active bool `json:"active,omitempty"` + Markable bool `json:"markable,omitempty"` } // Product type. type Product struct { BaseProduct - ID int `json:"id,omitempty"` - MaxPrice float32 `json:"maxPrice,omitempty"` - MinPrice float32 `json:"minPrice,omitempty"` - ImageURL string `json:"imageUrl,omitempty"` - Quantity float32 `json:"quantity,omitempty"` - Offers []Offer `json:"offers,omitempty"` - Properties StringMap `json:"properties,omitempty"` + ID int `json:"id,omitempty"` + MaxPrice float32 `json:"maxPrice,omitempty"` + MinPrice float32 `json:"minPrice,omitempty"` + ImageURL string `json:"imageUrl,omitempty"` + Quantity float32 `json:"quantity,omitempty"` + Offers []Offer `json:"offers,omitempty"` + Properties StringMap `json:"properties,omitempty"` + Groups []ProductGroup `json:"groups,omitempty"` } -// ProductEdit type. -type ProductEdit struct { - BaseProduct - ID int `json:"id,omitempty"` - CatalogID int `json:"catalogId,omitempty"` - Site string `json:"site,omitempty"` +// ProductEditGroupInput type. +type ProductEditGroupInput struct { + ID int `json:"id"` + ExternalID int `json:"externalId,omitempty"` } // ProductCreate type. type ProductCreate struct { BaseProduct - CatalogID int `json:"catalogId,omitempty"` + Groups []ProductEditGroupInput `json:"groups,omitempty"` + CatalogID int `json:"catalogId,omitempty"` +} + +// ProductEdit type. +type ProductEdit struct { + BaseProduct + ID int `json:"id,omitempty"` + CatalogID int `json:"catalogId,omitempty"` + Site string `json:"site,omitempty"` + Groups []ProductEditGroupInput `json:"groups,omitempty"` } // DeliveryHistoryRecord type. @@ -1042,9 +1070,11 @@ type Delivery struct { // DeliveryStatus type. type DeliveryStatus struct { - Code string `json:"code,omitempty"` - Name string `json:"name,omitempty"` - IsEditable bool `json:"isEditable,omitempty"` + Code string `json:"code,omitempty"` + Name string `json:"name,omitempty"` + IsEditable bool `json:"isEditable,omitempty"` + IsError bool `json:"isError,omitempty"` + IsPreprocessing bool `json:"isPreprocessing,omitempty"` } // Plate type. @@ -1250,3 +1280,62 @@ type OperationLoyalty struct { type CursorPagination struct { NextCursor string `json:"nextCursor,omitempty"` } + +// DeliveryTypeInfo type. +type DeliveryTypeInfo struct { + ID int `json:"id"` + Code string `json:"code"` +} + +// LoyaltyAccount type. +type LoyaltyAccount struct { + Active bool `json:"active"` + ID int `json:"id"` + PhoneNumber string `json:"phoneNumber,omitempty"` + CardNumber string `json:"cardNumber,omitempty"` + Amount float64 `json:"amount,omitempty"` + LoyaltyLevel LoyaltyLevel `json:"level"` + CreatedAt string `json:"createdAt,omitempty"` + ActivatedAt string `json:"activatedAt,omitempty"` + ConfirmedPhoneAt string `json:"confirmedPhoneAt,omitempty"` + LastCheckID int `json:"lastCheckId,omitempty"` + CustomFields []string `json:"customFields,omitempty"` + Loyalty Loyalty `json:"loyalty,omitempty"` + Customer Customer `json:"customer,omitempty"` + Status string `json:"status,omitempty"` + OrderSum float64 `json:"orderSum,omitempty"` + NextLevelSum float64 `json:"nextLevelSum,omitempty"` +} + +// Loyalty type. +type Loyalty struct { + ID int `json:"id"` +} + +// LoyaltyLevel type. +type LoyaltyLevel struct { + ID int `json:"id"` + Name string `json:"name"` + Type string `json:"type,omitempty"` + Sum float64 `json:"sum,omitempty"` + PrivilegeSize float64 `json:"privilegeSize,omitempty"` + PrivilegeSizePromo float64 `json:"privilegeSizePromo,omitempty"` +} + +type SmsVerification struct { + CreatedAt string `json:"createdAt"` + ExpiredAt string `json:"expiredAt"` + VerifiedAt string `json:"verifiedAt"` + CheckID string `json:"checkId"` + ActionType string `json:"actionType"` +} + +type LoyaltyBonus struct { + Amount float64 `json:"amount"` + ActivationDate string `json:"activationDate"` + ExpiredDate string `json:"expiredDate,omitempty"` +} + +type LoyaltyBonusApiFilterType struct { + Date string `url:"date,omitempty"` +}