Class: Payabli::Paypoint::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/payabli/paypoint/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



9
10
11
# File 'lib/payabli/paypoint/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#get_basic_entry(request_options: {}, **params) ⇒ Payabli::Paypoint::Types::GetBasicEntryResponse

Gets the basic details for a paypoint.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :entry (String)

Returns:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/payabli/paypoint/client.rb', line 25

def get_basic_entry(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "Paypoint/basic/#{URI.encode_uri_component(params[:entry].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Paypoint::Types::GetBasicEntryResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_basic_entry_by_id(request_options: {}, **params) ⇒ Payabli::Paypoint::Types::GetBasicEntryByIdResponse

Retrieves the basic details for a paypoint by ID.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id_paypoint (String)

Returns:



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/payabli/paypoint/client.rb', line 59

def get_basic_entry_by_id(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "Paypoint/basicById/#{URI.encode_uri_component(params[:id_paypoint].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Paypoint::Types::GetBasicEntryByIdResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_entry_config(request_options: {}, **params) ⇒ Payabli::Paypoint::Types::GetEntryConfigResponse

Gets the details for a single paypoint.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :entry (String)
  • :entrypages (String, nil)

Returns:



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/payabli/paypoint/client.rb', line 94

def get_entry_config(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[entrypages]
  query_params = {}
  query_params["entrypages"] = params[:entrypages] if params.key?(:entrypages)
  params = params.except(*query_param_names)

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "Paypoint/#{URI.encode_uri_component(params[:entry].to_s)}",
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Paypoint::Types::GetEntryConfigResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_page(request_options: {}, **params) ⇒ Payabli::Types::PayabliPages

Gets the details for single payment page for a paypoint.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :entry (String)
  • :subdomain (String)

Returns:



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/payabli/paypoint/client.rb', line 135

def get_page(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "Paypoint/#{URI.encode_uri_component(params[:entry].to_s)}/#{URI.encode_uri_component(params[:subdomain].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::PayabliPages.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#migrate(request_options: {}, **params) ⇒ Payabli::Paypoint::Types::MigratePaypointResponse

Migrates a paypoint to a new parent organization.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/payabli/paypoint/client.rb', line 272

def migrate(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "Paypoint/migrate",
    body: Payabli::Paypoint::Types::PaypointMoveRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Paypoint::Types::MigratePaypointResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#remove_page(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseGeneric2Part

Deletes a payment page in a paypoint.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :entry (String)
  • :subdomain (String)

Returns:



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/payabli/paypoint/client.rb', line 170

def remove_page(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "Paypoint/#{URI.encode_uri_component(params[:entry].to_s)}/#{URI.encode_uri_component(params[:subdomain].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::PayabliApiResponseGeneric2Part.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#save_logo(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse00Responsedatanonobject

Updates a paypoint logo.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :entry (String)

Returns:



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/payabli/paypoint/client.rb', line 204

def (request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PUT",
    path: "Paypoint/logo/#{URI.encode_uri_component(params[:entry].to_s)}",
    body: Payabli::Types::FileContent.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::PayabliApiResponse00Responsedatanonobject.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#settings_page(request_options: {}, **params) ⇒ Payabli::Types::SettingsQueryRecord

Retrieves an paypoint’s basic settings like custom fields, identifiers, and invoicing settings.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :entry (String)

Returns:



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/payabli/paypoint/client.rb', line 239

def settings_page(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "Paypoint/settings/#{URI.encode_uri_component(params[:entry].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::SettingsQueryRecord.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end