Class: Fastbound::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fastbound/client.rb

Constant Summary collapse

BASE_URL =
"https://cloud.fastbound.com"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, account_number:, audit_user: nil, base_url: BASE_URL) ⇒ Client

Returns a new instance of Client.

Raises:



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 .nil? || .empty?

  @api_key = api_key
  @account_number = 
  @audit_user = audit_user
  @base_url = base_url
end

Instance Attribute Details

#account_numberObject (readonly)

Returns the value of attribute account_number.



8
9
10
# File 'lib/fastbound/client.rb', line 8

def 
  @account_number
end

#audit_userObject (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

#accountObject



20
21
22
# File 'lib/fastbound/client.rb', line 20

def 
  @account ||= Resources::Account.new(self)
end

#acquisitionsObject



24
25
26
# File 'lib/fastbound/client.rb', line 24

def acquisitions
  @acquisitions ||= Resources::Acquisitions.new(self)
end

#attachmentsObject



28
29
30
# File 'lib/fastbound/client.rb', line 28

def attachments
  @attachments ||= Resources::Attachments.new(self)
end

#base_pathObject



101
102
103
# File 'lib/fastbound/client.rb', line 101

def base_path
  "/#{}/api"
end

#contactsObject



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

#dispositionsObject



36
37
38
# File 'lib/fastbound/client.rb', line 36

def dispositions
  @dispositions ||= Resources::Dispositions.new(self)
end

#downloadsObject



40
41
42
# File 'lib/fastbound/client.rb', line 40

def downloads
  @downloads ||= Resources::Downloads.new(self)
end

#form4473sObject



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

#inventoryObject



48
49
50
# File 'lib/fastbound/client.rb', line 48

def inventory
  @inventory ||= Resources::Inventory.new(self)
end

#itemsObject



52
53
54
# File 'lib/fastbound/client.rb', line 52

def items
  @items ||= Resources::Items.new(self)
end

#multiple_sale_reportsObject



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_listsObject



60
61
62
# File 'lib/fastbound/client.rb', line 60

def smart_lists
  @smart_lists ||= Resources::SmartLists.new(self)
end

#usersObject



64
65
66
# File 'lib/fastbound/client.rb', line 64

def users
  @users ||= Resources::Users.new(self)
end

#webhooksObject



68
69
70
# File 'lib/fastbound/client.rb', line 68

def webhooks
  @webhooks ||= Resources::Webhooks.new(self)
end