Class: MassPayRubySdk::AttributeApi

Inherits:
Object
  • Object
show all
Defined in:
lib/masspay_ruby_sdk/api/attribute_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ AttributeApi

Returns a new instance of AttributeApi.



18
19
20
# File 'lib/masspay_ruby_sdk/api/attribute_api.rb', line 18

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



16
17
18
# File 'lib/masspay_ruby_sdk/api/attribute_api.rb', line 16

def api_client
  @api_client
end

Instance Method Details

#get_attrs(currency, user_token, destination_token, opts = {}) ⇒ Array<AttrsRequirement>

Get user attributes for destination_token This GET endpoint is used to retrieve user attributes for a specific destination token.
You can use this endpoint to retrieve user attributes and provide personalized service to your users based on their preferences, demographic data, or other relevant information.
To use this endpoint, you need to provide the user_token, destination_token, and currency as parameters in the URL Path.
The endpoint will then return all the required attributes for the provided user for the specified destination token. If any of the attributes already have a stored value, it will be returned as well.

Parameters:

  • currency (String)

    The destination currency sending funds to. Using [ISO 4217](en.wikipedia.org/wiki/ISO_4217) format.

  • user_token (String)

    Token representing the user to retrieve attributes for

  • destination_token (String)

    Token that represents the payout destination i.e. Omnex-&gt;Brazil-&gt;Bank Deposit-&gt;Itau. To be retrieved from the #pricing callback.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

    Unique key to prevent duplicate processing

Returns:



29
30
31
32
# File 'lib/masspay_ruby_sdk/api/attribute_api.rb', line 29

def get_attrs(currency, user_token, destination_token, opts = {})
  data, _status_code, _headers = get_attrs_with_http_info(currency, user_token, destination_token, opts)
  data
end

#get_attrs_with_http_info(currency, user_token, destination_token, opts = {}) ⇒ Array<(Array<AttrsRequirement>, Integer, Hash)>

Get user attributes for destination_token This GET endpoint is used to retrieve user attributes for a specific destination token. &lt;br&gt; You can use this endpoint to retrieve user attributes and provide personalized service to your users based on their preferences, demographic data, or other relevant information. &lt;br&gt; To use this endpoint, you need to provide the &#x60;user_token&#x60;, &#x60;destination_token&#x60;, and currency as parameters in the URL Path. &lt;br&gt; The endpoint will then return all the required attributes for the provided user for the specified destination token. If any of the attributes already have a stored value, it will be returned as well.

Parameters:

  • currency (String)

    The destination currency sending funds to. Using [ISO 4217](en.wikipedia.org/wiki/ISO_4217) format.

  • user_token (String)

    Token representing the user to retrieve attributes for

  • destination_token (String)

    Token that represents the payout destination i.e. Omnex-&gt;Brazil-&gt;Bank Deposit-&gt;Itau. To be retrieved from the #pricing callback.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

    Unique key to prevent duplicate processing

Returns:

  • (Array<(Array<AttrsRequirement>, Integer, Hash)>)

    Array<AttrsRequirement> data, response status code and response headers



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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/masspay_ruby_sdk/api/attribute_api.rb', line 42

def get_attrs_with_http_info(currency, user_token, destination_token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttributeApi.get_attrs ...'
  end
  # verify the required parameter 'currency' is set
  if @api_client.config.client_side_validation && currency.nil?
    fail ArgumentError, "Missing the required parameter 'currency' when calling AttributeApi.get_attrs"
  end
  if @api_client.config.client_side_validation && currency.to_s.length > 3
    fail ArgumentError, 'invalid value for "currency" when calling AttributeApi.get_attrs, the character length must be smaller than or equal to 3.'
  end

  if @api_client.config.client_side_validation && currency.to_s.length < 3
    fail ArgumentError, 'invalid value for "currency" when calling AttributeApi.get_attrs, the character length must be great than or equal to 3.'
  end

  pattern = Regexp.new(/^[A-Z]{3}$/)
  if @api_client.config.client_side_validation && currency !~ pattern
    fail ArgumentError, "invalid value for 'currency' when calling AttributeApi.get_attrs, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'user_token' is set
  if @api_client.config.client_side_validation && user_token.nil?
    fail ArgumentError, "Missing the required parameter 'user_token' when calling AttributeApi.get_attrs"
  end
  # verify the required parameter 'destination_token' is set
  if @api_client.config.client_side_validation && destination_token.nil?
    fail ArgumentError, "Missing the required parameter 'destination_token' when calling AttributeApi.get_attrs"
  end
  # resource path
  local_var_path = '/attribute/{user_token}/{destination_token}/{currency}'.sub('{' + 'currency' + '}', CGI.escape(currency.to_s)).sub('{' + 'user_token' + '}', CGI.escape(user_token.to_s)).sub('{' + 'destination_token' + '}', CGI.escape(destination_token.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Array<AttrsRequirement>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['AUTHORIZER_NAME']

  new_options = opts.merge(
    :operation => :"AttributeApi.get_attrs",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AttributeApi#get_attrs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#store_attrs(currency, user_token, destination_token, attr_txn, opts = {}) ⇒ nil

Store user attributes This POST endpoint is used to store user attributes, allowing you to associate additional data with a user token.
To use this endpoint, you need to provide the user_token, destination_token, and currency as parameters in the URL Path. You also need to provide the attribute values as JSON parameters in the Request body.
If existing attributes are already stored for the user, this call will override their values.

Parameters:

  • currency (String)

    The destination currency sending funds to. Using [ISO 4217](en.wikipedia.org/wiki/ISO_4217) format.

  • user_token (String)

    Token representing the user to store attributes for

  • destination_token (String)

    Token that represents the payout destination i.e. Omnex-&gt;Brazil-&gt;Bank Deposit-&gt;Itau. To be retrieved from the #pricing callback.

  • attr_txn (AttrTxn)

    Attr parameters to store

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

    Unique key to prevent duplicate processing

Returns:

  • (nil)


121
122
123
124
# File 'lib/masspay_ruby_sdk/api/attribute_api.rb', line 121

def store_attrs(currency, user_token, destination_token, attr_txn, opts = {})
  store_attrs_with_http_info(currency, user_token, destination_token, attr_txn, opts)
  nil
end

#store_attrs_with_http_info(currency, user_token, destination_token, attr_txn, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Store user attributes This POST endpoint is used to store user attributes, allowing you to associate additional data with a user token. &lt;br&gt; To use this endpoint, you need to provide the &#x60;user_token&#x60;, &#x60;destination_token&#x60;, and currency as parameters in the URL Path. You also need to provide the attribute values as JSON parameters in the Request body. &lt;br&gt; If existing attributes are already stored for the user, this call will override their values.

Parameters:

  • currency (String)

    The destination currency sending funds to. Using [ISO 4217](en.wikipedia.org/wiki/ISO_4217) format.

  • user_token (String)

    Token representing the user to store attributes for

  • destination_token (String)

    Token that represents the payout destination i.e. Omnex-&gt;Brazil-&gt;Bank Deposit-&gt;Itau. To be retrieved from the #pricing callback.

  • attr_txn (AttrTxn)

    Attr parameters to store

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

    Unique key to prevent duplicate processing

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



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
160
161
162
163
164
165
166
167
168
169
170
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
206
207
208
209
210
211
212
# File 'lib/masspay_ruby_sdk/api/attribute_api.rb', line 135

def store_attrs_with_http_info(currency, user_token, destination_token, attr_txn, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttributeApi.store_attrs ...'
  end
  # verify the required parameter 'currency' is set
  if @api_client.config.client_side_validation && currency.nil?
    fail ArgumentError, "Missing the required parameter 'currency' when calling AttributeApi.store_attrs"
  end
  if @api_client.config.client_side_validation && currency.to_s.length > 3
    fail ArgumentError, 'invalid value for "currency" when calling AttributeApi.store_attrs, the character length must be smaller than or equal to 3.'
  end

  if @api_client.config.client_side_validation && currency.to_s.length < 3
    fail ArgumentError, 'invalid value for "currency" when calling AttributeApi.store_attrs, the character length must be great than or equal to 3.'
  end

  pattern = Regexp.new(/^[A-Z]{3}$/)
  if @api_client.config.client_side_validation && currency !~ pattern
    fail ArgumentError, "invalid value for 'currency' when calling AttributeApi.store_attrs, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'user_token' is set
  if @api_client.config.client_side_validation && user_token.nil?
    fail ArgumentError, "Missing the required parameter 'user_token' when calling AttributeApi.store_attrs"
  end
  # verify the required parameter 'destination_token' is set
  if @api_client.config.client_side_validation && destination_token.nil?
    fail ArgumentError, "Missing the required parameter 'destination_token' when calling AttributeApi.store_attrs"
  end
  # verify the required parameter 'attr_txn' is set
  if @api_client.config.client_side_validation && attr_txn.nil?
    fail ArgumentError, "Missing the required parameter 'attr_txn' when calling AttributeApi.store_attrs"
  end
  # resource path
  local_var_path = '/attribute/{user_token}/{destination_token}/{currency}'.sub('{' + 'currency' + '}', CGI.escape(currency.to_s)).sub('{' + 'user_token' + '}', CGI.escape(user_token.to_s)).sub('{' + 'destination_token' + '}', CGI.escape(destination_token.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(attr_txn)

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['AUTHORIZER_NAME']

  new_options = opts.merge(
    :operation => :"AttributeApi.store_attrs",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AttributeApi#store_attrs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end