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, request_options: nil) ⇒ Object
api.agents.create(name: “name”, description: “description”).
-
#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: { }).
-
#update_by_external_id(external_id:, request:, request_options: nil) ⇒ Object
api.agents.update_by_external_id(external_id: “externalId”, request: { }).
Constructor Details
#initialize(request_client:) ⇒ Paid::AsyncAgentsClient
279 280 281 |
# File 'lib/paid_ruby/agents/client.rb', line 279 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Paid::AsyncRequestClient (readonly)
274 275 276 |
# File 'lib/paid_ruby/agents/client.rb', line 274 def request_client @request_client end |
Instance Method Details
#create(name:, description:, agent_code: nil, external_id: nil, request_options: nil) ⇒ Object
api.agents.create(name: “name”, description: “description”)
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/paid_ruby/agents/client.rb', line 329 def create(name:, description:, agent_code: nil, external_id: 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 }.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”)
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/paid_ruby/agents/client.rb', line 425 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”)
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
# File 'lib/paid_ruby/agents/client.rb', line 522 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”)
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/paid_ruby/agents/client.rb', line 358 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”)
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
# File 'lib/paid_ruby/agents/client.rb', line 455 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
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'lib/paid_ruby/agents/client.rb', line 291 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: { })
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
# File 'lib/paid_ruby/agents/client.rb', line 396 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: { })
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
# File 'lib/paid_ruby/agents/client.rb', line 493 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 |