Class: FastBound::Acquisition
- Inherits:
-
Base
- Object
- Base
- FastBound::Acquisition
show all
- Includes:
- API
- Defined in:
- lib/fastbound-ruby/acquisition.rb
Constant Summary
collapse
- CREATE_AND_EDIT_ATTRS =
{
permitted: %i(
external_id is_manufacturing_acquisition purchase_order_number
date type note invoice_number shipment_tracking_number
).freeze,
required: %i( type ).freeze
}
- ENDPOINTS =
{
list: "acquisitions".freeze,
create: "acquisitions".freeze,
edit: "acquisitions/%s".freeze,
fetch: "acquisitions/%s".freeze,
fetch_by_external_id: "acquisitions/getbyexternalid/%s".freeze,
delete: "acquisitions/%s".freeze,
commit: "acquisitions/%s/commit".freeze,
create_and_commit: "acquisitions/createandcommit".freeze,
create_item: "acquisitions/%s/items".freeze,
edit_item: "acquisitions/%s/items/%s".freeze,
fetch_item: "acquisitions/%s/items/%s".freeze,
delete_item: "acquisitions/%s/items/%s".freeze,
attach_contact: "acquisitions/%s/attachcontact/%s".freeze
}
Constants included
from API
FastBound::API::FILE_UPLOAD_ATTRS, FastBound::API::ROOT_URL, FastBound::API::USER_AGENT
Instance Method Summary
collapse
Methods included from API
#delete_request, #get_request, #post_file_request, #post_request, #put_request
Constructor Details
Returns a new instance of Acquisition.
32
33
34
|
# File 'lib/fastbound-ruby/acquisition.rb', line 32
def initialize(client)
@client = client
end
|
Instance Method Details
126
127
128
129
130
|
# File 'lib/fastbound-ruby/acquisition.rb', line 126
def attach_contact(acquisition_id, contact_id)
endpoint = ENDPOINTS[:attach_contact] % [acquisition_id, contact_id]
put_request(@client, endpoint)
end
|
#commit(acquisition_id) ⇒ Object
76
77
78
79
80
|
# File 'lib/fastbound-ruby/acquisition.rb', line 76
def commit(acquisition_id)
endpoint = ENDPOINTS[:commit] % acquisition_id
post_request(@client, endpoint)
end
|
#create(acquisition_data) ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/fastbound-ruby/acquisition.rb', line 42
def create(acquisition_data)
requires!(acquisition_data, *CREATE_AND_EDIT_ATTRS[:required])
endpoint = ENDPOINTS[:create]
acquisition_data = standardize_body_data(acquisition_data, CREATE_AND_EDIT_ATTRS[:permitted])
post_request(@client, endpoint, acquisition_data)
end
|
#create_and_commit(acquisition_data, item_data, contact_data) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/fastbound-ruby/acquisition.rb', line 82
def create_and_commit(acquisition_data, item_data, contact_data)
requires!(acquisition_data, *CREATE_AND_EDIT_ATTRS[:required])
requires!(item_data, *Item::CREATE_AND_EDIT_ATTRS[:required])
endpoint = ENDPOINTS[:create_and_commit]
acquisition_data = standardize_body_data(acquisition_data, CREATE_AND_EDIT_ATTRS[:permitted])
item_data = standardize_body_data(item_data, Item::CREATE_AND_EDIT_ATTRS[:permitted])
contact_data = standardize_body_data(contact_data, Contact::CREATE_AND_EDIT_ATTRS)
request_data = acquisition_data.merge(
contact: contact_data,
items: [item_data]
)
post_request(@client, endpoint, request_data)
end
|
#create_item(acquisition_id, item_data) ⇒ Object
98
99
100
101
102
103
104
105
|
# File 'lib/fastbound-ruby/acquisition.rb', line 98
def create_item(acquisition_id, item_data)
requires!(item_data, *Item::CREATE_AND_EDIT_ATTRS[:required])
endpoint = ENDPOINTS[:create_item] % acquisition_id
item_data = standardize_body_data(item_data, Item::CREATE_AND_EDIT_ATTRS[:permitted])
post_request(@client, endpoint, item_data)
end
|
#delete(acquisition_id) ⇒ Object
70
71
72
73
74
|
# File 'lib/fastbound-ruby/acquisition.rb', line 70
def delete(acquisition_id)
endpoint = ENDPOINTS[:delete] % acquisition_id
delete_request(@client, endpoint)
end
|
#delete_item(acquisition_id, item_id) ⇒ Object
120
121
122
123
124
|
# File 'lib/fastbound-ruby/acquisition.rb', line 120
def delete_item(acquisition_id, item_id)
endpoint = ENDPOINTS[:delete_item] % [acquisition_id, item_id]
delete_request(@client, endpoint)
end
|
#edit(acquisition_id, acquisition_data) ⇒ Object
51
52
53
54
55
56
|
# File 'lib/fastbound-ruby/acquisition.rb', line 51
def edit(acquisition_id, acquisition_data)
endpoint = ENDPOINTS[:edit] % acquisition_id
acquisition_data = standardize_body_data(acquisition_data, CREATE_AND_EDIT_ATTRS[:permitted])
put_request(@client, endpoint, acquisition_data)
end
|
#edit_item(acquisition_id, item_id, item_data) ⇒ Object
107
108
109
110
111
112
|
# File 'lib/fastbound-ruby/acquisition.rb', line 107
def edit_item(acquisition_id, item_id, item_data)
endpoint = ENDPOINTS[:edit_item] % [acquisition_id, item_id]
item_data = standardize_body_data(item_data, Item::CREATE_AND_EDIT_ATTRS[:permitted])
put_request(@client, endpoint, item_data)
end
|
#fetch(acquisition_id) ⇒ Object
58
59
60
61
62
|
# File 'lib/fastbound-ruby/acquisition.rb', line 58
def fetch(acquisition_id)
endpoint = ENDPOINTS[:fetch] % acquisition_id
get_request(@client, endpoint)
end
|
#fetch_by_external_id(external_id) ⇒ Object
64
65
66
67
68
|
# File 'lib/fastbound-ruby/acquisition.rb', line 64
def fetch_by_external_id(external_id)
endpoint = ENDPOINTS[:fetch_by_external_id] % external_id
get_request(@client, endpoint)
end
|
#fetch_item(acquisition_id, item_id) ⇒ Object
114
115
116
117
118
|
# File 'lib/fastbound-ruby/acquisition.rb', line 114
def fetch_item(acquisition_id, item_id)
endpoint = ENDPOINTS[:fetch_item] % [acquisition_id, item_id]
get_request(@client, endpoint)
end
|
#list(params = {}) ⇒ Object
36
37
38
39
40
|
# File 'lib/fastbound-ruby/acquisition.rb', line 36
def list(params = {})
endpoint = ENDPOINTS[:list] % convert_params_to_request_query(params)
get_request(@client, endpoint)
end
|