Class: Paid::AsyncCustomersClient
- Inherits:
-
Object
- Object
- Paid::AsyncCustomersClient
- Defined in:
- lib/paid_ruby/customers/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(name:, external_id: nil, phone: nil, employee_count: nil, annual_revenue: nil, tax_exempt_status: nil, creation_source: nil, website: nil, billing_address: nil, request_options: nil) ⇒ Object
api.customers.create(name: “Acme, Inc.”, external_id: “acme-inc”).
-
#delete(customer_id:, request_options: nil) ⇒ Object
api.customers.delete(customer_id: “customerId”).
-
#delete_by_external_id(external_id:, request_options: nil) ⇒ Object
api.customers.delete_by_external_id(external_id: “externalId”).
-
#get(customer_id:, request_options: nil) ⇒ Object
api.customers.get(customer_id: “customerId”).
-
#get_by_external_id(external_id:, request_options: nil) ⇒ Object
api.customers.get_by_external_id(external_id: “externalId”).
- #initialize(request_client:) ⇒ Paid::AsyncCustomersClient constructor
-
#list(request_options: nil) ⇒ Object
api.customers.list.
-
#update(customer_id:, request:, request_options: nil) ⇒ Object
api.customers.update(customer_id: “customerId”, request: { name: “Acme, Inc. (Updated)”, phone: “123-456-7890”, employee_count: 101, annual_revenue: 1000001 }).
-
#update_by_external_id(external_id:, request:, request_options: nil) ⇒ Object
api.customers.update_by_external_id(external_id: “externalId”, request: { }).
Constructor Details
#initialize(request_client:) ⇒ Paid::AsyncCustomersClient
311 312 313 |
# File 'lib/paid_ruby/customers/client.rb', line 311 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Paid::AsyncRequestClient (readonly)
306 307 308 |
# File 'lib/paid_ruby/customers/client.rb', line 306 def request_client @request_client end |
Instance Method Details
#create(name:, external_id: nil, phone: nil, employee_count: nil, annual_revenue: nil, tax_exempt_status: nil, creation_source: nil, website: nil, billing_address: nil, request_options: nil) ⇒ Object
api.customers.create(name: “Acme, Inc.”, external_id: “acme-inc”)
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
# File 'lib/paid_ruby/customers/client.rb', line 372 def create(name:, external_id: nil, phone: nil, employee_count: nil, annual_revenue: nil, tax_exempt_status: nil, creation_source: nil, website: nil, billing_address: 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 || {}), name: name, externalId: external_id, phone: phone, employeeCount: employee_count, annualRevenue: annual_revenue, taxExemptStatus: tax_exempt_status, creationSource: creation_source, website: website, billingAddress: billing_address }.compact req.url "#{@request_client.get_url(request_options: )}/customers" end Paid::Customer.from_json(json_object: response.body) end end |
#delete(customer_id:, request_options: nil) ⇒ Object
api.customers.delete(customer_id: “customerId”)
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
# File 'lib/paid_ruby/customers/client.rb', line 477 def delete(customer_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: )}/customers/#{customer_id}" end end end |
#delete_by_external_id(external_id:, request_options: nil) ⇒ Object
api.customers.delete_by_external_id(external_id: “externalId”)
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
# File 'lib/paid_ruby/customers/client.rb', line 583 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: )}/customers/external/#{external_id}" end end end |
#get(customer_id:, request_options: nil) ⇒ Object
api.customers.get(customer_id: “customerId”)
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'lib/paid_ruby/customers/client.rb', line 401 def get(customer_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: )}/customers/#{customer_id}" end Paid::Customer.from_json(json_object: response.body) end end |
#get_by_external_id(external_id:, request_options: nil) ⇒ Object
api.customers.get_by_external_id(external_id: “externalId”)
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
# File 'lib/paid_ruby/customers/client.rb', line 507 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: )}/customers/external/#{external_id}" end Paid::Customer.from_json(json_object: response.body) end end |
#list(request_options: nil) ⇒ Object
api.customers.list
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/paid_ruby/customers/client.rb', line 323 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: )}/customers" end parsed_json = JSON.parse(response.body) parsed_json&.map do | item | item = item.to_json Paid::Customer.from_json(json_object: item) end end end |
#update(customer_id:, request:, request_options: nil) ⇒ Object
api.customers.update(customer_id: “customerId”, request: { name: “Acme, Inc. (Updated)”, phone: “123-456-7890”, employee_count: 101, annual_revenue: 1000001 })
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 |
# File 'lib/paid_ruby/customers/client.rb', line 448 def update(customer_id:, request:, request_options: nil) Async do response = @request_client.conn.put 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 = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(request_options: )}/customers/#{customer_id}" end Paid::Customer.from_json(json_object: response.body) end end |
#update_by_external_id(external_id:, request:, request_options: nil) ⇒ Object
api.customers.update_by_external_id(external_id: “externalId”, request: { })
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
# File 'lib/paid_ruby/customers/client.rb', line 554 def update_by_external_id(external_id:, request:, request_options: nil) Async do response = @request_client.conn.put 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 = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(request_options: )}/customers/external/#{external_id}" end Paid::Customer.from_json(json_object: response.body) end end |