Class: SibApiV3Sdk::AttributesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/sib-api-v3-sdk/api/attributes_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ AttributesApi



19
20
21
# File 'lib/sib-api-v3-sdk/api/attributes_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/sib-api-v3-sdk/api/attributes_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_attribute(attribute_category, attribute_name, create_attribute, opts = {}) ⇒ nil

Create contact attribute



38
39
40
41
# File 'lib/sib-api-v3-sdk/api/attributes_api.rb', line 38

def create_attribute(attribute_category, attribute_name, create_attribute, opts = {})
  create_attribute_with_http_info(attribute_category, attribute_name, create_attribute, opts)
  nil
end

#create_attribute_with_http_info(attribute_category, attribute_name, create_attribute, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Create contact attribute



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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/sib-api-v3-sdk/api/attributes_api.rb', line 49

def create_attribute_with_http_info(attribute_category, attribute_name, create_attribute, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttributesApi.create_attribute ...'
  end
  # verify the required parameter 'attribute_category' is set
  if @api_client.config.client_side_validation && attribute_category.nil?
    fail ArgumentError, "Missing the required parameter 'attribute_category' when calling AttributesApi.create_attribute"
  end
  # verify enum value
  if @api_client.config.client_side_validation && !['normal', 'transactional', 'category', 'calculated', 'global'].include?(attribute_category)
    fail ArgumentError, "invalid value for 'attribute_category', must be one of normal, transactional, category, calculated, global"
  end
  # verify the required parameter 'attribute_name' is set
  if @api_client.config.client_side_validation && attribute_name.nil?
    fail ArgumentError, "Missing the required parameter 'attribute_name' when calling AttributesApi.create_attribute"
  end
  # verify the required parameter 'create_attribute' is set
  if @api_client.config.client_side_validation && create_attribute.nil?
    fail ArgumentError, "Missing the required parameter 'create_attribute' when calling AttributesApi.create_attribute"
  end
  # resource path
  local_var_path = '/contacts/attributes/{attributeCategory}/{attributeName}'.sub('{' + 'attributeCategory' + '}', attribute_category.to_s).sub('{' + 'attributeName' + '}', attribute_name.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(create_attribute)
  auth_names = ['api-key', 'partner-key']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AttributesApi#create_attribute\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_attribute(attribute_category, attribute_name, opts = {}) ⇒ nil

Delete an attribute



104
105
106
107
# File 'lib/sib-api-v3-sdk/api/attributes_api.rb', line 104

def delete_attribute(attribute_category, attribute_name, opts = {})
  delete_attribute_with_http_info(attribute_category, attribute_name, opts)
  nil
end

#delete_attribute_with_http_info(attribute_category, attribute_name, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Delete an attribute



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/sib-api-v3-sdk/api/attributes_api.rb', line 114

def delete_attribute_with_http_info(attribute_category, attribute_name, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttributesApi.delete_attribute ...'
  end
  # verify the required parameter 'attribute_category' is set
  if @api_client.config.client_side_validation && attribute_category.nil?
    fail ArgumentError, "Missing the required parameter 'attribute_category' when calling AttributesApi.delete_attribute"
  end
  # verify enum value
  if @api_client.config.client_side_validation && !['normal', 'transactional', 'category', 'calculated', 'global'].include?(attribute_category)
    fail ArgumentError, "invalid value for 'attribute_category', must be one of normal, transactional, category, calculated, global"
  end
  # verify the required parameter 'attribute_name' is set
  if @api_client.config.client_side_validation && attribute_name.nil?
    fail ArgumentError, "Missing the required parameter 'attribute_name' when calling AttributesApi.delete_attribute"
  end
  # resource path
  local_var_path = '/contacts/attributes/{attributeCategory}/{attributeName}'.sub('{' + 'attributeCategory' + '}', attribute_category.to_s).sub('{' + 'attributeName' + '}', attribute_name.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api-key', 'partner-key']
  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AttributesApi#delete_attribute\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_attributes(opts = {}) ⇒ GetAttributes

List all attributes



163
164
165
166
# File 'lib/sib-api-v3-sdk/api/attributes_api.rb', line 163

def get_attributes(opts = {})
  data, _status_code, _headers = get_attributes_with_http_info(opts)
  data
end

#get_attributes_with_http_info(opts = {}) ⇒ Array<(GetAttributes, Fixnum, Hash)>

List all attributes



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/sib-api-v3-sdk/api/attributes_api.rb', line 171

def get_attributes_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttributesApi.get_attributes ...'
  end
  # resource path
  local_var_path = '/contacts/attributes'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api-key', 'partner-key']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'GetAttributes')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AttributesApi#get_attributes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#setUserAgent(user_agent) ⇒ Object

Set custom user_agent if explicitly passed in api default will still remain Swagger-Codegen/#VERSION/ruby



25
26
27
28
29
30
# File 'lib/sib-api-v3-sdk/api/attributes_api.rb', line 25

def setUserAgent(user_agent)
  @user_agent = user_agent
  if user_agent.is_a?(String) && user_agent.downcase.start_with?('sendinblue_')
    @api_client.default_headers['User-Agent'] = @user_agent
  end
end

#update_attribute(attribute_category, attribute_name, update_attribute, opts = {}) ⇒ nil

Update contact attribute



212
213
214
215
# File 'lib/sib-api-v3-sdk/api/attributes_api.rb', line 212

def update_attribute(attribute_category, attribute_name, update_attribute, opts = {})
  update_attribute_with_http_info(attribute_category, attribute_name, update_attribute, opts)
  nil
end

#update_attribute_with_http_info(attribute_category, attribute_name, update_attribute, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Update contact attribute



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/sib-api-v3-sdk/api/attributes_api.rb', line 223

def update_attribute_with_http_info(attribute_category, attribute_name, update_attribute, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttributesApi.update_attribute ...'
  end
  # verify the required parameter 'attribute_category' is set
  if @api_client.config.client_side_validation && attribute_category.nil?
    fail ArgumentError, "Missing the required parameter 'attribute_category' when calling AttributesApi.update_attribute"
  end
  # verify enum value
  if @api_client.config.client_side_validation && !['category', 'calculated', 'global'].include?(attribute_category)
    fail ArgumentError, "invalid value for 'attribute_category', must be one of category, calculated, global"
  end
  # verify the required parameter 'attribute_name' is set
  if @api_client.config.client_side_validation && attribute_name.nil?
    fail ArgumentError, "Missing the required parameter 'attribute_name' when calling AttributesApi.update_attribute"
  end
  # verify the required parameter 'update_attribute' is set
  if @api_client.config.client_side_validation && update_attribute.nil?
    fail ArgumentError, "Missing the required parameter 'update_attribute' when calling AttributesApi.update_attribute"
  end
  # resource path
  local_var_path = '/contacts/attributes/{attributeCategory}/{attributeName}'.sub('{' + 'attributeCategory' + '}', attribute_category.to_s).sub('{' + 'attributeName' + '}', attribute_name.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(update_attribute)
  auth_names = ['api-key', 'partner-key']
  data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AttributesApi#update_attribute\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end