/
configuration.go
executable file
·79 lines (69 loc) · 6.97 KB
/
configuration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* SendX REST API
*
* **NOTE:** All API calls contain 2 parameters - 'api_key' and 'team_id'. These can be inferred from your settings page 'https://app.sendx.io/setting' under the sections 'Api Key' and 'Team Id' respectively. For checking language specific Clients: - [Golang](https://github.com/sendx/sendx-api-go) - [Python](https://github.com/sendx/sendx-api-python) - [Ruby](https://github.com/sendx/sendx-api-ruby) - [Java](https://github.com/sendx/sendx-api-java) - [PHP](https://github.com/sendx/sendx-api-php) - [NodeJS](https://github.com/sendx/sendx-api-nodejs) We also have a [Javascript API](http://help.sendx.io/knowledge_base/topics/javascript-api-1) for client side integrations. SendX REST API has two methods: * Identify * Track ## Identify API Method Identify API Method is used to attach data to a visitor. If a contact is not yet created then we will create the contact. In case contact already exists then we update it. **Example Request:** ```json { email: \"john.doe@gmail.com\", firstName: \"John\", lastName: \"Doe\", birthday: \"1989-03-03\", customFields: { \"Designation\": \"Software Engineer\", \"Age\": \"27\", \"Experience\": \"5\" }, tags: [\"Developer\", \"API Team\"], } ``` Note that tags are an array of strings. In case they don't exist previously then API will create them and associate them with the contact. Similarly if a custom field doesn't exist then it is first created and then associated with the contact along-with the corresponding value. In case custom field exists already then we simply update the value of it for the aforementioned contact. We don't delete any of the properties based on identify call. What this means is that if for the same contact you did two API calls like: **API Call A** ```json { email: \"john.doe@gmail.com\", firstName: \"John\", birthday: \"1989-03-03\", customFields: { \"Designation\": \"Software Engineer\" }, tags: [\"Developer\"], } ``` **API Call B** ```json { email: \"john.doe@gmail.com\", customFields: { \"Age\": \"29\" }, tags: [\"API Team\"], } ``` Then the final contact will have firstName as **John**, birthday as **1989-03-03** present. Also both tags **Developer** and **API Team** shall be present along with custom fields **Designation** and **Age**. **Properties:** * **firstName**: type string * **lastName**: type string * **email**: type string * **newEmail**: type string * **company**: type string * **birthday**: type string with format **YYYY-MM-DD** eg: 2016-11-21 * **customFields**: type map[string]string * **tags**: type array of string In case email of an already existing contact needs to be updated then specify current email under email property and updated email under newEmail property. **Response:** ```json { \"status\": \"200\", \"message\": \"OK\", \"data\": { \"encryptedTeamId\": \"CLdh9Ig5GLIN1u8gTRvoja\", \"encryptedId\": \"c9QF63nrBenCaAXe660byz\", \"tags\": [ \"API Team\", \"Tech\" ], \"firstName\": \"John\", \"lastName\": \"Doe\", \"email\": \"john.doe@gmail.com\", \"company\": \"\", \"birthday\": \"1989-03-03\", \"customFields\": { \"Age\": \"29\", \"Designation\": \"Software Engineer\" } } } ``` ## Track API Method Track API Method is used to track a contact. In the track API object you can: * **addTags**: * **removeTags**: You can have automation rules based on tag addition as well as tag removal and they will get executed. For eg: * On **user registration** tag start onboarding drip for him / her. * **Account Upgrade** tag start add user to paid user list and start account expansion drip. * On removal of **trial user** tag start upsell trial completed users drip. **Example Request:** > \\_scq.push([\"track\", { \"addTags\": [\"blogger\", \"female\"] }]); > \\_scq.push([\"track\", { \"addTags\": [\"paid user\"], \"removeTags\": [\"trial user\"] }]); **Response:** > { \"status\": \"200\", \"message\": \"OK\", \"data\": \"success\" }
*
* OpenAPI spec version: v1
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package swagger
import (
"encoding/base64"
"net/http"
"time"
)
type Configuration struct {
UserName string `json:"userName,omitempty"`
Password string `json:"password,omitempty"`
APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"`
APIKey map[string]string `json:"APIKey,omitempty"`
Debug bool `json:"debug,omitempty"`
DebugFile string `json:"debugFile,omitempty"`
OAuthToken string `json:"oAuthToken,omitempty"`
BasePath string `json:"basePath,omitempty"`
Host string `json:"host,omitempty"`
Scheme string `json:"scheme,omitempty"`
AccessToken string `json:"accessToken,omitempty"`
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
APIClient *APIClient
Transport *http.Transport
Timeout *time.Duration `json:"timeout,omitempty"`
}
func NewConfiguration() *Configuration {
cfg := &Configuration{
BasePath: "https://app.sendx.io/api/v1",
DefaultHeader: make(map[string]string),
APIKey: make(map[string]string),
APIKeyPrefix: make(map[string]string),
UserAgent: "Swagger-Codegen/1.0.0/go",
APIClient: &APIClient{},
}
cfg.APIClient.config = cfg
return cfg
}
func (c *Configuration) GetBasicAuthEncodedString() string {
return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password))
}
func (c *Configuration) AddDefaultHeader(key string, value string) {
c.DefaultHeader[key] = value
}
func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string {
if c.APIKeyPrefix[APIKeyIdentifier] != "" {
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
}
return c.APIKey[APIKeyIdentifier]
}