Class: Paid::AsyncAgentsClient
- Inherits:
-
Object
- Object
- Paid::AsyncAgentsClient
- Defined in:
- lib/paid_ruby/agents/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(name:, description:, agent_code: nil, external_id: nil, active: nil, request_options: nil) ⇒ Object
).
-
#delete(agent_id:, request_options: nil) ⇒ Object
api.agents.delete(agent_id: “agentId”).
-
#delete_by_external_id(external_id:, request_options: nil) ⇒ Object
api.agents.delete_by_external_id(external_id: “externalId”).
-
#get(agent_id:, request_options: nil) ⇒ Object
api.agents.get(agent_id: “agentId”).
-
#get_by_external_id(external_id:, request_options: nil) ⇒ Object
api.agents.get_by_external_id(external_id: “externalId”).
- #initialize(request_client:) ⇒ Paid::AsyncAgentsClient constructor
-
#list(request_options: nil) ⇒ Object
api.agents.list.
-
#update(agent_id:, request:, request_options: nil) ⇒ Object
api.agents.update(agent_id: “agentId”, request: { name: “Acme Agent (Updated)”, agent_attributes: [{ name: “Emails sent signal”, active: true, pricing: { event_name: “emails_sent”, taxable: true, charge_type: USAGE, pricing_model: PER_UNIT, billing_frequency: MONTHLY, price_points: { “USD”: { tiers: [{ min_quantity: 0, max_quantity: 10, unit_price: 100 }, { min_quantity: 11, max_quantity: 100, unit_price: 90 }, { min_quantity: 101, unit_price: 80 }] } } } }] }).
-
#update_by_external_id(external_id:, request:, request_options: nil) ⇒ Object
api.agents.update_by_external_id(external_id: “externalId”, request: { name: “Acme Agent (Updated)”, agent_attributes: [{ name: “Emails sent signal”, active: true, pricing: { event_name: “emails_sent”, taxable: true, charge_type: USAGE, pricing_model: PER_UNIT, billing_frequency: MONTHLY, price_points: { “USD”: { unit_price: 150 } } } }] }).
Constructor Details
#initialize(request_client:) ⇒ Paid::AsyncAgentsClient
284 285 286 |
# File 'lib/paid_ruby/agents/client.rb', line 284 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Paid::AsyncRequestClient (readonly)
279 280 281 |
# File 'lib/paid_ruby/agents/client.rb', line 279 def request_client @request_client end |
Instance Method Details
#create(name:, description:, agent_code: nil, external_id: nil, active: nil, request_options: nil) ⇒ Object
)
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/paid_ruby/agents/client.rb', line 339 def create(name:, description:, agent_code: nil, external_id: nil, active: 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, description: description, agentCode: agent_code, externalId: external_id, active: active }.compact req.url "#{@request_client.get_url(request_options: )}/agents" end Paid::Agent.from_json(json_object: response.body) end end |
#delete(agent_id:, request_options: nil) ⇒ Object
api.agents.delete(agent_id: “agentId”)
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
# File 'lib/paid_ruby/agents/client.rb', line 435 def delete(agent_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: )}/agents/#{agent_id}" end end end |
#delete_by_external_id(external_id:, request_options: nil) ⇒ Object
api.agents.delete_by_external_id(external_id: “externalId”)
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
# File 'lib/paid_ruby/agents/client.rb', line 532 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: )}/agents/external/#{external_id}" end end end |
#get(agent_id:, request_options: nil) ⇒ Object
api.agents.get(agent_id: “agentId”)
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
# File 'lib/paid_ruby/agents/client.rb', line 368 def get(agent_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: )}/agents/#{agent_id}" end Paid::Agent.from_json(json_object: response.body) end end |
#get_by_external_id(external_id:, request_options: nil) ⇒ Object
api.agents.get_by_external_id(external_id: “externalId”)
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 |
# File 'lib/paid_ruby/agents/client.rb', line 465 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: )}/agents/external/#{external_id}" end Paid::Agent.from_json(json_object: response.body) end end |
#list(request_options: nil) ⇒ Object
api.agents.list
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/paid_ruby/agents/client.rb', line 296 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: )}/agents" end parsed_json = JSON.parse(response.body) parsed_json&.map do | item | item = item.to_json Paid::Agent.from_json(json_object: item) end end end |
#update(agent_id:, request:, request_options: nil) ⇒ Object
api.agents.update(agent_id: “agentId”, request: { name: “Acme Agent (Updated)”, agent_attributes: [{ name: “Emails sent signal”, active: true, pricing: { event_name: “emails_sent”, taxable: true, charge_type: USAGE, pricing_model: PER_UNIT, billing_frequency: MONTHLY, price_points: { “USD”: { tiers: [{ min_quantity: 0, max_quantity: 10, unit_price: 100 }, { min_quantity: 11, max_quantity: 100, unit_price: 90 }, { min_quantity: 101, unit_price: 80 }] } } } }] })
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/paid_ruby/agents/client.rb', line 406 def update(agent_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: )}/agents/#{agent_id}" end Paid::Agent.from_json(json_object: response.body) end end |
#update_by_external_id(external_id:, request:, request_options: nil) ⇒ Object
api.agents.update_by_external_id(external_id: “externalId”, request: { name: “Acme Agent (Updated)”, agent_attributes: [{ name: “Emails sent signal”, active: true, pricing: { event_name: “emails_sent”, taxable: true, charge_type: USAGE, pricing_model: PER_UNIT, billing_frequency: MONTHLY, price_points: { “USD”: { unit_price: 150 } } } }] })
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
# File 'lib/paid_ruby/agents/client.rb', line 503 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: )}/agents/external/#{external_id}" end Paid::Agent.from_json(json_object: response.body) end end |