Class: Payabli::Vendor::Client
- Inherits:
-
Object
- Object
- Payabli::Vendor::Client
- Defined in:
- lib/payabli/vendor/client.rb
Instance Method Summary collapse
-
#add_vendor(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseVendors
Creates a vendor in an entrypoint.
-
#delete_vendor(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseVendors
Delete a vendor.
-
#edit_vendor(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseVendors
Updates a vendor's information.
-
#enrich_vendor(request_options: {}, **params) ⇒ Payabli::Types::VendorEnrichResponse
Triggers AI-powered vendor enrichment for an existing vendor.
-
#get_enrichment_call_status(request_options: {}, **params) ⇒ Payabli::Types::VendorCallStatusResponse
Returns the latest AI outreach call activity for a vendor.
-
#get_vendor(request_options: {}, **params) ⇒ Payabli::Types::VendorQueryRecord
Retrieves a vendor's details, including enrichment status and payment acceptance info when available.
- #initialize(client:) ⇒ void constructor
-
#schedule_enrichment_call(request_options: {}, **params) ⇒ Payabli::Types::VendorScheduleCallResponse
Schedules an AI outreach call to a vendor to collect their preferred payment method and contact email.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/payabli/vendor/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#add_vendor(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseVendors
Creates a vendor in an entrypoint.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/payabli/vendor/client.rb', line 72 def add_vendor(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) path_param_names = %i[entry] body_params = params.except(*path_param_names) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "Vendor/single/#{URI.encode_uri_component(params[:entry].to_s)}", headers: headers, body: Payabli::Types::VendorData.new(body_params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponseVendors.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete_vendor(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseVendors
Delete a vendor.
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/payabli/vendor/client.rb', line 200 def delete_vendor(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "Vendor/#{URI.encode_uri_component(params[:id_vendor].to_s)}", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponseVendors.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#edit_vendor(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseVendors
Updates a vendor's information. Send only the fields you need to update.
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/payabli/vendor/client.rb', line 157 def edit_vendor(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) path_param_names = %i[id_vendor] body_params = params.except(*path_param_names) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "Vendor/#{URI.encode_uri_component(params[:id_vendor].to_s)}", headers: headers, body: Payabli::Types::VendorData.new(body_params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponseVendors.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#enrich_vendor(request_options: {}, **params) ⇒ Payabli::Types::VendorEnrichResponse
Triggers AI-powered vendor enrichment for an existing vendor. Runs one or more enrichment stages (invoice scan,
web search) based on the scope parameter. Can automatically apply extracted payment acceptance info and vendor
contact information to the vendor record, or return raw results for manual review. Contact Payabli to enable
this feature.
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/payabli/vendor/client.rb', line 253 def enrich_vendor(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request_data = Payabli::Vendor::Types::VendorEnrichRequest.new(params).to_h non_body_param_names = %w[entry] body = request_data.except(*non_body_param_names) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "Vendor/enrich/#{URI.encode_uri_component(params[:entry].to_s)}", headers: headers, body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::VendorEnrichResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_enrichment_call_status(request_options: {}, **params) ⇒ Payabli::Types::VendorCallStatusResponse
Returns the latest AI outreach call activity for a vendor. The response is a composite object with a state
discriminator (none, scheduled, successful, or failed); the block that matches the current state is
populated. When the vendor has no call activity, state is none and the response returns HTTP 200.
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/payabli/vendor/client.rb', line 356 def get_enrichment_call_status(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Vendor/#{URI.encode_uri_component(params[:id_vendor].to_s)}/enrichment/call-status", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::VendorCallStatusResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_vendor(request_options: {}, **params) ⇒ Payabli::Types::VendorQueryRecord
Retrieves a vendor's details, including enrichment status and payment acceptance info when available.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/payabli/vendor/client.rb', line 115 def get_vendor(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Vendor/#{URI.encode_uri_component(params[:id_vendor].to_s)}", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::VendorQueryRecord.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#schedule_enrichment_call(request_options: {}, **params) ⇒ Payabli::Types::VendorScheduleCallResponse
Schedules an AI outreach call to a vendor to collect their preferred payment method and contact email. This is the third enrichment stage. Calls are scheduled for the next business day at around 9 AM in the vendor's timezone, with retries on no-answer and a fallback payment method applied when retries are exhausted. This feature is opt-in at the org level. Contact your Payabli representative to enable it, provision a phone number, and discuss pricing.
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/payabli/vendor/client.rb', line 310 def schedule_enrichment_call(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request_data = Payabli::Vendor::Types::ScheduleEnrichmentCallRequest.new(params).to_h non_body_param_names = %w[entry] body = request_data.except(*non_body_param_names) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "Vendor/enrich/schedule_call/#{URI.encode_uri_component(params[:entry].to_s)}", headers: headers, body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::VendorScheduleCallResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |