Class: Fastbound::Client
- Inherits:
-
Object
- Object
- Fastbound::Client
- Defined in:
- lib/fastbound/client.rb
Constant Summary collapse
- BASE_URL =
"https://cloud.fastbound.com"
Instance Attribute Summary collapse
-
#account_number ⇒ Object
readonly
Returns the value of attribute account_number.
-
#audit_user ⇒ Object
readonly
Returns the value of attribute audit_user.
Instance Method Summary collapse
- #account ⇒ Object
- #acquisitions ⇒ Object
- #attachments ⇒ Object
- #base_path ⇒ Object
- #contacts ⇒ Object
- #delete(path, audit: true) ⇒ Object
- #dispositions ⇒ Object
- #downloads ⇒ Object
- #form4473s ⇒ Object
- #get(path, params = {}) ⇒ Object
- #get_binary(path) ⇒ Object
-
#initialize(api_key:, account_number:, audit_user: nil, base_url: BASE_URL) ⇒ Client
constructor
A new instance of Client.
- #inventory ⇒ Object
- #items ⇒ Object
- #multiple_sale_reports ⇒ Object
- #post(path, body = {}, audit: true) ⇒ Object
- #post_binary(path, body = {}, audit: true) ⇒ Object
- #put(path, body = {}, audit: true) ⇒ Object
- #smart_lists ⇒ Object
- #users ⇒ Object
- #webhooks ⇒ Object
Constructor Details
#initialize(api_key:, account_number:, audit_user: nil, base_url: BASE_URL) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 |
# File 'lib/fastbound/client.rb', line 10 def initialize(api_key:, account_number:, audit_user: nil, base_url: BASE_URL) raise ConfigurationError, "api_key is required" if api_key.nil? || api_key.empty? raise ConfigurationError, "account_number is required" if account_number.nil? || account_number.empty? @api_key = api_key @account_number = account_number @audit_user = audit_user @base_url = base_url end |
Instance Attribute Details
#account_number ⇒ Object (readonly)
Returns the value of attribute account_number.
8 9 10 |
# File 'lib/fastbound/client.rb', line 8 def account_number @account_number end |
#audit_user ⇒ Object (readonly)
Returns the value of attribute audit_user.
8 9 10 |
# File 'lib/fastbound/client.rb', line 8 def audit_user @audit_user end |
Instance Method Details
#account ⇒ Object
20 21 22 |
# File 'lib/fastbound/client.rb', line 20 def account @account ||= Resources::Account.new(self) end |
#acquisitions ⇒ Object
24 25 26 |
# File 'lib/fastbound/client.rb', line 24 def acquisitions @acquisitions ||= Resources::Acquisitions.new(self) end |
#attachments ⇒ Object
28 29 30 |
# File 'lib/fastbound/client.rb', line 28 def @attachments ||= Resources::Attachments.new(self) end |
#base_path ⇒ Object
101 102 103 |
# File 'lib/fastbound/client.rb', line 101 def base_path "/#{account_number}/api" end |
#contacts ⇒ Object
32 33 34 |
# File 'lib/fastbound/client.rb', line 32 def contacts @contacts ||= Resources::Contacts.new(self) end |
#delete(path, audit: true) ⇒ Object
84 85 86 |
# File 'lib/fastbound/client.rb', line 84 def delete(path, audit: true) request(:delete, path, audit: audit) end |
#dispositions ⇒ Object
36 37 38 |
# File 'lib/fastbound/client.rb', line 36 def dispositions @dispositions ||= Resources::Dispositions.new(self) end |
#downloads ⇒ Object
40 41 42 |
# File 'lib/fastbound/client.rb', line 40 def downloads @downloads ||= Resources::Downloads.new(self) end |
#form4473s ⇒ Object
44 45 46 |
# File 'lib/fastbound/client.rb', line 44 def form4473s @form4473s ||= Resources::Form4473s.new(self) end |
#get(path, params = {}) ⇒ Object
72 73 74 |
# File 'lib/fastbound/client.rb', line 72 def get(path, params = {}) request(:get, path, params: compact(params)) end |
#get_binary(path) ⇒ Object
88 89 90 91 |
# File 'lib/fastbound/client.rb', line 88 def get_binary(path) response = connection.get(path) handle_response(response, raw: true) end |
#inventory ⇒ Object
48 49 50 |
# File 'lib/fastbound/client.rb', line 48 def inventory @inventory ||= Resources::Inventory.new(self) end |
#items ⇒ Object
52 53 54 |
# File 'lib/fastbound/client.rb', line 52 def items @items ||= Resources::Items.new(self) end |
#multiple_sale_reports ⇒ Object
56 57 58 |
# File 'lib/fastbound/client.rb', line 56 def multiple_sale_reports @multiple_sale_reports ||= Resources::MultipleSaleReports.new(self) end |
#post(path, body = {}, audit: true) ⇒ Object
76 77 78 |
# File 'lib/fastbound/client.rb', line 76 def post(path, body = {}, audit: true) request(:post, path, body: body, audit: audit) end |
#post_binary(path, body = {}, audit: true) ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/fastbound/client.rb', line 93 def post_binary(path, body = {}, audit: true) response = connection(audit: audit).post(path) do |req| req.body = body.to_json req.headers["Content-Type"] = "application/json" end handle_response(response, raw: true) end |
#put(path, body = {}, audit: true) ⇒ Object
80 81 82 |
# File 'lib/fastbound/client.rb', line 80 def put(path, body = {}, audit: true) request(:put, path, body: body, audit: audit) end |
#smart_lists ⇒ Object
60 61 62 |
# File 'lib/fastbound/client.rb', line 60 def smart_lists @smart_lists ||= Resources::SmartLists.new(self) end |