seko 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +23 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +210 -0
  8. data/Rakefile +1 -0
  9. data/lib/seko/client.rb +236 -0
  10. data/lib/seko/company.rb +33 -0
  11. data/lib/seko/dispatch.rb +22 -0
  12. data/lib/seko/filter.rb +9 -0
  13. data/lib/seko/order.rb +77 -0
  14. data/lib/seko/product.rb +27 -0
  15. data/lib/seko/receipt.rb +36 -0
  16. data/lib/seko/response.rb +33 -0
  17. data/lib/seko/shipping.rb +26 -0
  18. data/lib/seko/stock.rb +9 -0
  19. data/lib/seko/tracking.rb +22 -0
  20. data/lib/seko/version.rb +3 -0
  21. data/lib/seko.rb +31 -0
  22. data/seko.gemspec +27 -0
  23. data/spec/fixtures/company_submit.json +21 -0
  24. data/spec/fixtures/dispatch_statuses.json +25 -0
  25. data/spec/fixtures/grn.json +45 -0
  26. data/spec/fixtures/order_status.json +11 -0
  27. data/spec/fixtures/order_submit.json +33 -0
  28. data/spec/fixtures/order_tracking.json +12 -0
  29. data/spec/fixtures/order_websubmit.json +29 -0
  30. data/spec/fixtures/product_submit.json +15 -0
  31. data/spec/fixtures/receipt_submit.json +26 -0
  32. data/spec/fixtures/stock.json +29 -0
  33. data/spec/fixtures/stock_adjustment.json +7 -0
  34. data/spec/fixtures/stock_movement.json +7 -0
  35. data/spec/lib/client_spec.rb +364 -0
  36. data/spec/lib/company_spec.rb +22 -0
  37. data/spec/lib/dispatch_spec.rb +17 -0
  38. data/spec/lib/filter_spec.rb +12 -0
  39. data/spec/lib/order_spec.rb +60 -0
  40. data/spec/lib/product_spec.rb +23 -0
  41. data/spec/lib/receipt_spec.rb +36 -0
  42. data/spec/lib/response_spec.rb +53 -0
  43. data/spec/lib/stock_spec.rb +12 -0
  44. data/spec/logs/spec.log +0 -0
  45. data/spec/spec_helper.rb +176 -0
  46. metadata +196 -0
@@ -0,0 +1,176 @@
1
+ require 'codeclimate-test-reporter'
2
+ CodeClimate::TestReporter.start
3
+ require 'bundler/setup'
4
+ require 'seko'
5
+ require 'rspec'
6
+ require 'webmock/rspec'
7
+ require 'hashie'
8
+
9
+ Bundler.setup
10
+
11
+ WebMock.disable_net_connect!(:allow => "codeclimate.com")
12
+
13
+ RSpec.configure do |config|
14
+ config.include WebMock::API
15
+ config.before(:all, &:silence_output)
16
+ config.after(:all, &:enable_output)
17
+ end
18
+
19
+ def read_json(type)
20
+ File.read( File.expand_path("spec/fixtures/#{type}.json") )
21
+ end
22
+
23
+ def fixture(type)
24
+ JSON.parse( read_json(type) )
25
+ end
26
+
27
+ def base_url
28
+ 'https://hubuat1.supplystream.com/hub/api/'
29
+ end
30
+
31
+ def stub_get(path)
32
+ stub_request(:get, "#{base_url}#{path}")
33
+ end
34
+
35
+ def stub_post(path)
36
+ stub_request(:post, "#{base_url}#{path}")
37
+ end
38
+
39
+ def json_headers
40
+ { content_type: 'application/json; charset=utf-8' }
41
+ end
42
+
43
+ def json_post_headers
44
+ {
45
+ 'Accept' => '*/*',
46
+ 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
47
+ 'Content-Type' => 'application/json',
48
+ 'User-Agent' => 'Ruby'
49
+ }
50
+ end
51
+
52
+ def success_response
53
+ {
54
+ 'Response' => {
55
+ 'CallStatus' => {
56
+ 'Code' => 0,
57
+ 'Message' => {},
58
+ 'Success' => true
59
+ }
60
+ }
61
+ }
62
+ end
63
+
64
+ def error_product_response
65
+ {
66
+ 'CallStatus' => {
67
+ 'Success' => false,
68
+ 'Code' => 100,
69
+ 'Message' => 'Error Submitting Product Master: LJ-W-BERN-S-GW - Error. Product Code already exists.'
70
+ }
71
+ }
72
+ end
73
+
74
+ def configuration
75
+ {
76
+ supplier_code: 'Supplier1',
77
+ supplier_description: 'My Supplier',
78
+ supplier_uom: 1,
79
+ warehouses: {},
80
+ token: 'token123'
81
+ }
82
+ end
83
+
84
+ def address_hash
85
+ {
86
+ city: 'Windsor',
87
+ country: 'GB',
88
+ first_name: 'Stephen',
89
+ last_name: 'Jones',
90
+ address1: '23 Victoria Street',
91
+ address2: '',
92
+ phone: '0123 336 6676',
93
+ zipcode: 'SL4 1HE'
94
+ }
95
+ end
96
+
97
+ def line_items_array
98
+ [
99
+ {
100
+ sku: 100083,
101
+ quantity: 2
102
+ }
103
+ ]
104
+ end
105
+
106
+ def company_hash
107
+ {
108
+ code: 'IND001',
109
+ description: 'Indigina'
110
+ }
111
+ end
112
+
113
+ def order_hash
114
+ {
115
+ number: 123456,
116
+ email: 'stephen.jones@gmail.com',
117
+ shipping_address: address_hash,
118
+ line_items: line_items_array,
119
+ warehouse: 'DC123',
120
+ date: '2013-12-12'
121
+ }
122
+ end
123
+
124
+ def company_order_hash
125
+ order_hash.merge(company: company_hash)
126
+ end
127
+
128
+ def company_address_hash
129
+ {
130
+ city: 'High Wycombe',
131
+ country: 'GB',
132
+ country_name: 'Buckinghamshire',
133
+ address1: 'The Farthings',
134
+ address2: 'Sandpits Lane',
135
+ address3: 'Beaconsfield',
136
+ zipcode: 'HP8 TTT'
137
+ }
138
+ end
139
+
140
+ def company_submit_hash
141
+ {
142
+ code: 123456,
143
+ description: 'My Test company',
144
+ address: company_address_hash
145
+ }
146
+ end
147
+
148
+ def fake_response
149
+ Hashie::Mash.new({body: {test: true}.to_json})
150
+ end
151
+
152
+
153
+ public
154
+ # Redirects stderr and stout to /log/spec.log
155
+ def silence_output
156
+ # Store the original stderr and stdout in order to restore them later
157
+ @original_stderr = $stderr
158
+ @original_stdout = $stdout
159
+
160
+ # Redirect stderr and stdout
161
+ $stderr = File.new(log_file, 'w')
162
+ $stdout = File.new(log_file, 'w')
163
+ end
164
+
165
+ def log_file
166
+ File.join(File.dirname(__FILE__), 'logs', 'spec.log')
167
+ end
168
+
169
+ # Replace stderr and stdout so anything else is output correctly
170
+ def enable_output
171
+ $stderr = @original_stderr
172
+ $stdout = @original_stdout
173
+ @original_stderr = nil
174
+ @original_stdout = nil
175
+ `rm #{log_file} && touch #{log_file}`
176
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: seko
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Justin Grubbs
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: hashie
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: codeclimate-test-reporter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: A ruby wrapper for interfacing with Seko Logistics' SupplySteam iHub
98
+ API
99
+ email:
100
+ - justin@jgrubbs.net
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - .rspec
107
+ - .travis.yml
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - lib/seko.rb
113
+ - lib/seko/client.rb
114
+ - lib/seko/company.rb
115
+ - lib/seko/dispatch.rb
116
+ - lib/seko/filter.rb
117
+ - lib/seko/order.rb
118
+ - lib/seko/product.rb
119
+ - lib/seko/receipt.rb
120
+ - lib/seko/response.rb
121
+ - lib/seko/shipping.rb
122
+ - lib/seko/stock.rb
123
+ - lib/seko/tracking.rb
124
+ - lib/seko/version.rb
125
+ - seko.gemspec
126
+ - spec/fixtures/company_submit.json
127
+ - spec/fixtures/dispatch_statuses.json
128
+ - spec/fixtures/grn.json
129
+ - spec/fixtures/order_status.json
130
+ - spec/fixtures/order_submit.json
131
+ - spec/fixtures/order_tracking.json
132
+ - spec/fixtures/order_websubmit.json
133
+ - spec/fixtures/product_submit.json
134
+ - spec/fixtures/receipt_submit.json
135
+ - spec/fixtures/stock.json
136
+ - spec/fixtures/stock_adjustment.json
137
+ - spec/fixtures/stock_movement.json
138
+ - spec/lib/client_spec.rb
139
+ - spec/lib/company_spec.rb
140
+ - spec/lib/dispatch_spec.rb
141
+ - spec/lib/filter_spec.rb
142
+ - spec/lib/order_spec.rb
143
+ - spec/lib/product_spec.rb
144
+ - spec/lib/receipt_spec.rb
145
+ - spec/lib/response_spec.rb
146
+ - spec/lib/stock_spec.rb
147
+ - spec/logs/spec.log
148
+ - spec/spec_helper.rb
149
+ homepage: https://github.com/jGRUBBS/seko-ruby-api
150
+ licenses:
151
+ - MIT
152
+ metadata: {}
153
+ post_install_message:
154
+ rdoc_options: []
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - '>='
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ requirements: []
168
+ rubyforge_project:
169
+ rubygems_version: 2.0.6
170
+ signing_key:
171
+ specification_version: 4
172
+ summary: A ruby wrapper for interfacing with Seko Logistics' SupplySteam iHub API
173
+ test_files:
174
+ - spec/fixtures/company_submit.json
175
+ - spec/fixtures/dispatch_statuses.json
176
+ - spec/fixtures/grn.json
177
+ - spec/fixtures/order_status.json
178
+ - spec/fixtures/order_submit.json
179
+ - spec/fixtures/order_tracking.json
180
+ - spec/fixtures/order_websubmit.json
181
+ - spec/fixtures/product_submit.json
182
+ - spec/fixtures/receipt_submit.json
183
+ - spec/fixtures/stock.json
184
+ - spec/fixtures/stock_adjustment.json
185
+ - spec/fixtures/stock_movement.json
186
+ - spec/lib/client_spec.rb
187
+ - spec/lib/company_spec.rb
188
+ - spec/lib/dispatch_spec.rb
189
+ - spec/lib/filter_spec.rb
190
+ - spec/lib/order_spec.rb
191
+ - spec/lib/product_spec.rb
192
+ - spec/lib/receipt_spec.rb
193
+ - spec/lib/response_spec.rb
194
+ - spec/lib/stock_spec.rb
195
+ - spec/logs/spec.log
196
+ - spec/spec_helper.rb