Class: Paid::AgentsClient
- Inherits:
-
Object
- Object
- Paid::AgentsClient
- 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::AgentsClient 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::AgentsClient
24 25 26 |
# File 'lib/paid_ruby/agents/client.rb', line 24 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Paid::RequestClient (readonly)
19 20 21 |
# File 'lib/paid_ruby/agents/client.rb', line 19 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”)
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/paid_ruby/agents/client.rb', line 72 def create(name:, description:, agent_code: nil, external_id: nil, request_options: nil) 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 |
#delete(agent_id:, request_options: nil) ⇒ Object
api.agents.delete(agent_id: “agentId”)
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/paid_ruby/agents/client.rb', line 162 def delete(agent_id:, request_options: nil) 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 |
#delete_by_external_id(external_id:, request_options: nil) ⇒ Object
api.agents.delete_by_external_id(external_id: “externalId”)
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/paid_ruby/agents/client.rb', line 253 def delete_by_external_id(external_id:, request_options: nil) 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 |
#get(agent_id:, request_options: nil) ⇒ Object
api.agents.get(agent_id: “agentId”)
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/paid_ruby/agents/client.rb', line 99 def get(agent_id:, request_options: nil) 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 |
#get_by_external_id(external_id:, request_options: nil) ⇒ Object
api.agents.get_by_external_id(external_id: “externalId”)
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/paid_ruby/agents/client.rb', line 190 def get_by_external_id(external_id:, request_options: nil) 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 |
#list(request_options: nil) ⇒ Object
api.agents.list
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/paid_ruby/agents/client.rb', line 36 def list(request_options: nil) 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 |
#update(agent_id:, request:, request_options: nil) ⇒ Object
api.agents.update(agent_id: “agentId”, request: { })
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/paid_ruby/agents/client.rb', line 135 def update(agent_id:, request:, request_options: nil) 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 |
#update_by_external_id(external_id:, request:, request_options: nil) ⇒ Object
api.agents.update_by_external_id(external_id: “externalId”, request: { })
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/paid_ruby/agents/client.rb', line 226 def update_by_external_id(external_id:, request:, request_options: nil) 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 |