Class: Paid::AsyncContactsClient
- Inherits:
-
Object
- Object
- Paid::AsyncContactsClient
- Defined in:
- lib/paid_ruby/contacts/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(external_id: nil, customer_id: nil, customer_external_id: nil, salutation:, first_name:, last_name:, email:, phone: nil, billing_street: nil, billing_city: nil, billing_state_province: nil, billing_country: nil, billing_postal_code: nil, request_options: nil) ⇒ Object
).
-
#delete(contact_id:, request_options: nil) ⇒ Object
api.contacts.delete(contact_id: “contactId”).
-
#delete_by_external_id(external_id:, request_options: nil) ⇒ Object
api.contacts.delete_by_external_id(external_id: “externalId”).
-
#get(contact_id:, request_options: nil) ⇒ Object
api.contacts.get(contact_id: “contactId”).
-
#get_by_external_id(external_id:, request_options: nil) ⇒ Object
api.contacts.get_by_external_id(external_id: “externalId”).
- #initialize(request_client:) ⇒ Paid::AsyncContactsClient constructor
-
#list(request_options: nil) ⇒ Object
api.contacts.list.
Constructor Details
#initialize(request_client:) ⇒ Paid::AsyncContactsClient
224 225 226 |
# File 'lib/paid_ruby/contacts/client.rb', line 224 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Paid::AsyncRequestClient (readonly)
219 220 221 |
# File 'lib/paid_ruby/contacts/client.rb', line 219 def request_client @request_client end |
Instance Method Details
#create(external_id: nil, customer_id: nil, customer_external_id: nil, salutation:, first_name:, last_name:, email:, phone: nil, billing_street: nil, billing_city: nil, billing_state_province: nil, billing_country: nil, billing_postal_code: nil, request_options: nil) ⇒ Object
)
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/paid_ruby/contacts/client.rb', line 289 def create(external_id: nil, customer_id: nil, customer_external_id: nil, salutation:, first_name:, last_name:, email:, phone: nil, billing_street: nil, billing_city: nil, billing_state_province: nil, billing_country: nil, billing_postal_code: nil, request_options: nil) Async do response = @request_client.conn.post do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), externalId: external_id, customerId: customer_id, customerExternalId: customer_external_id, salutation: salutation, firstName: first_name, lastName: last_name, email: email, phone: phone, billingStreet: billing_street, billingCity: billing_city, billingStateProvince: billing_state_province, billingCountry: billing_country, billingPostalCode: billing_postal_code }.compact req.url "#{@request_client.get_url(request_options: )}/contacts" end Paid::Contact.from_json(json_object: response.body) end end |
#delete(contact_id:, request_options: nil) ⇒ Object
api.contacts.delete(contact_id: “contactId”)
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
# File 'lib/paid_ruby/contacts/client.rb', line 349 def delete(contact_id:, request_options: nil) Async do response = @request_client.conn.delete do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/contacts/#{contact_id}" end end end |
#delete_by_external_id(external_id:, request_options: nil) ⇒ Object
api.contacts.delete_by_external_id(external_id: “externalId”)
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
# File 'lib/paid_ruby/contacts/client.rb', line 410 def delete_by_external_id(external_id:, request_options: nil) Async do response = @request_client.conn.delete do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/contacts/external/#{external_id}" end end end |
#get(contact_id:, request_options: nil) ⇒ Object
api.contacts.get(contact_id: “contactId”)
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/paid_ruby/contacts/client.rb', line 318 def get(contact_id:, request_options: nil) Async do response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/contacts/#{contact_id}" end Paid::Contact.from_json(json_object: response.body) end end |
#get_by_external_id(external_id:, request_options: nil) ⇒ Object
api.contacts.get_by_external_id(external_id: “externalId”)
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/paid_ruby/contacts/client.rb', line 379 def get_by_external_id(external_id:, request_options: nil) Async do response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/contacts/external/#{external_id}" end Paid::Contact.from_json(json_object: response.body) end end |
#list(request_options: nil) ⇒ Object
api.contacts.list
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 |
# File 'lib/paid_ruby/contacts/client.rb', line 236 def list(request_options: nil) Async do response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/contacts" end parsed_json = JSON.parse(response.body) parsed_json&.map do | item | item = item.to_json Paid::Contact.from_json(json_object: item) end end end |