Class: Bizowie::API
- Inherits:
-
Object
- Object
- Bizowie::API
- Defined in:
- lib/bizowie/api.rb,
lib/bizowie/api/version.rb,
lib/bizowie/api/response.rb
Overview
Ruby client for the Bizowie ERP API.
Defined Under Namespace
Classes: Response
Constant Summary collapse
- USER_AGENT =
'Bizowie::API'.freeze
- VERSION =
'0.5.0'.freeze
Instance Method Summary collapse
-
#call(method, params = nil) ⇒ Bizowie::API::Response
Make an API call.
-
#initialize(api_key:, secret_key:, site:, v2: false, api_version: nil, debug: false) ⇒ API
constructor
A new instance of API.
Constructor Details
#initialize(api_key:, secret_key:, site:, v2: false, api_version: nil, debug: false) ⇒ API
Returns a new instance of API.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bizowie/api.rb', line 35 def initialize(api_key:, secret_key:, site:, v2: false, api_version: nil, debug: false) raise ArgumentError, 'site not specified' if site.nil? || site.to_s.empty? raise ArgumentError, 'api_key not specified' if api_key.nil? || api_key.to_s.empty? raise ArgumentError, 'secret_key not specified' if secret_key.nil? || secret_key.to_s.empty? @api_key = api_key @secret_key = secret_key @site = site @v2 = v2 @api_version = api_version @debug = debug end |
Instance Method Details
#call(method, params = nil) ⇒ Bizowie::API::Response
Make an API call. Dispatches to the v1 or v2 endpoint based on the v2 option passed to the constructor.
Does not raise on HTTP errors — application-level failures are surfaced via success: 0 on the returned response. Network-level failures (DNS, connection refused, TLS errors) bubble up from Net::HTTP.
62 63 64 |
# File 'lib/bizowie/api.rb', line 62 def call(method, params = nil) @v2 ? call_v2(method, params) : call_v1(method, params) end |