fastbound-ruby 1.1.1 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5636145d94a788e369f51bd5c3118b9858eec7815c91460f91258bde3736cf0b
4
- data.tar.gz: '01187f1976e1658b14d38c2831c1a2d3635ad431f7e55818556ad1c4c9fc99ce'
3
+ metadata.gz: e1ddd372f0736a3153b3f7e3004b77edc4f4a472856a4b47bde3dd888e653546
4
+ data.tar.gz: 87ee6aba545cae8ddb3748b1190910a9542f313bb3f2e04466690e549716e85c
5
5
  SHA512:
6
- metadata.gz: cfbcbd5aa9a90c184b7bcda0bc5051eb3da82da5ebbf6d4c3af268e52b8fa74e8d0ac771b949eb93e5b0c084cd0f99b22deb88525a5d6ac7b4bd99b69f256d51
7
- data.tar.gz: e4b762a8f4deb99b58a638ecdb3a1b79426cd6bf40fcae3f9862d5dab1d057d3e5e1757dbd7dcdbae8b97a525b477a132393fc1152775950673526e5820d508d
6
+ metadata.gz: 489f34169de6fb6865505271bc54a5f2ff1beb3c81a9123084da897165f7bed229c77d96298af9d6cc8c0f9b712b43cb8c4edcabe360023237a00ac2c26dc4e9
7
+ data.tar.gz: f99ec40017fc51153d88ab9799511a74f432ebdbcda5b38e70845d92d1ee9d11c188aff309b48f709324718feccb287318abf0aa04d59e23f821a62f1c6ceeef
@@ -82,12 +82,11 @@ module FastBound
82
82
  def create_and_commit(acquisition_data, item_data, contact_data)
83
83
  requires!(acquisition_data, *CREATE_AND_EDIT_ATTRS[:required])
84
84
  requires!(item_data, *Item::CREATE_AND_EDIT_ATTRS[:required])
85
- requires!(contact_data, *Contact::CREATE_AND_EDIT_ATTRS[:required])
86
85
 
87
86
  endpoint = ENDPOINTS[:create_and_commit]
88
87
  acquisition_data = standardize_body_data(acquisition_data, CREATE_AND_EDIT_ATTRS[:permitted])
89
88
  item_data = standardize_body_data(item_data, Item::CREATE_AND_EDIT_ATTRS[:permitted])
90
- contact_data = standardize_body_data(contact_data, Contact::CREATE_AND_EDIT_ATTRS[:permitted])
89
+ contact_data = standardize_body_data(contact_data, Contact::CREATE_AND_EDIT_ATTRS)
91
90
  request_data = acquisition_data.merge(
92
91
  contact: contact_data,
93
92
  items: [item_data]
@@ -62,11 +62,12 @@ module FastBound
62
62
 
63
63
  def process_request(request)
64
64
  uri = URI(request.path)
65
+ http = Net::HTTP.new(uri.host, uri.port)
65
66
 
66
- response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
67
- http.set_debug_output($stdout) if FastBound.config.full_debug?
68
- http.request(request)
69
- end
67
+ http.use_ssl = true
68
+ http.set_debug_output($stdout) if FastBound.config.full_debug?
69
+
70
+ response = http.start { |_http| _http.request(request) }
70
71
 
71
72
  FastBound::Response.new(response)
72
73
  end
@@ -5,14 +5,11 @@ module FastBound
5
5
 
6
6
  include FastBound::API
7
7
 
8
- CREATE_AND_EDIT_ATTRS = {
9
- permitted: %i(
10
- external_id ffl_number ffl_expires lookup_ffl license_name trade_name sotein sot_class business_type
11
- organization_name first_name middle_name last_name premise_address_1 premise_address_2 premise_city
12
- premise_county premise_state premise_zip_code premise_country phone_number fax email_address
13
- ).freeze,
14
- required: %i( ffl_number ffl_expires premise_address_1 premise_city premise_state premise_zip_code ).freeze
15
- }
8
+ CREATE_AND_EDIT_ATTRS = %i(
9
+ external_id ffl_number ffl_expires lookup_ffl license_name trade_name sotein sot_class business_type
10
+ organization_name first_name middle_name last_name premise_address_1 premise_address_2 premise_city
11
+ premise_county premise_state premise_zip_code premise_country phone_number fax email_address
12
+ ).freeze
16
13
 
17
14
  CREATE_AND_EDIT_LICENSE_ATTRS = {
18
15
  permitted: %i( type number expiration copy_on_file ).freeze,
@@ -49,17 +46,15 @@ module FastBound
49
46
  end
50
47
 
51
48
  def create(contact_data)
52
- requires!(contact_data, *CREATE_AND_EDIT_ATTRS[:required])
53
-
54
49
  endpoint = ENDPOINTS[:create]
55
- contact_data = standardize_body_data(contact_data, CREATE_AND_EDIT_ATTRS[:permitted])
50
+ contact_data = standardize_body_data(contact_data, CREATE_AND_EDIT_ATTRS)
56
51
 
57
52
  post_request(@client, endpoint, contact_data)
58
53
  end
59
54
 
60
55
  def edit(contact_id, contact_data)
61
56
  endpoint = ENDPOINTS[:edit] % contact_id
62
- contact_data = standardize_body_data(contact_data, CREATE_AND_EDIT_ATTRS[:permitted])
57
+ contact_data = standardize_body_data(contact_data, CREATE_AND_EDIT_ATTRS)
63
58
 
64
59
  put_request(@client, endpoint, contact_data)
65
60
  end
@@ -152,19 +152,18 @@ module FastBound
152
152
  post_request(@client, endpoint, commit_data)
153
153
  end
154
154
 
155
- def create_and_commit(disposition_data, items_data, contact_data, commit_data = {})
156
- requires!(contact_data, *Contact::CREATE_AND_EDIT_ATTRS[:required])
155
+ def create_and_commit(disposition_data, items_data, contact_data = {}, commit_data = {})
157
156
  items_data.each { |item| requires!(item, :id) }
158
157
 
159
158
  endpoint = ENDPOINTS[:create_and_commit]
160
159
  disposition_data = standardize_body_data(disposition_data, EDIT_AND_CREATE_COMMIT_ATTRS)
161
160
  items_data = items_data.map { |item| standardize_body_data(item, ITEM_ATTRS[:add]) }
162
- contact_data = standardize_body_data(contact_data, Contact::CREATE_AND_EDIT_ATTRS[:permitted])
161
+ contact_data = standardize_body_data(contact_data, Contact::CREATE_AND_EDIT_ATTRS)
163
162
  request_data = disposition_data.merge(
164
163
  contact: contact_data,
165
164
  items: items_data,
166
165
  manufacturingChanges: commit_data
167
- )
166
+ ).compact
168
167
 
169
168
  post_request(@client, endpoint, request_data)
170
169
  end
@@ -24,6 +24,10 @@ module FastBound
24
24
  _data.map(&:deep_symbolize_keys)
25
25
  end
26
26
  else
27
+ if FastBound.config.full_debug?
28
+ puts "-- DEBUG: #{self}: RequestError: #{@response.inspect}"
29
+ end
30
+
27
31
  raise FastBound::Error::RequestError.new(@response.body)
28
32
  end
29
33
  end
@@ -1,3 +1,3 @@
1
1
  module FastBound
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastbound-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey Dill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-14 00:00:00.000000000 Z
11
+ date: 2022-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler