shipstation 0.25 → 0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -20
  3. data/Rakefile +30 -30
  4. data/lib/shipstation/api_operations/create.rb +10 -10
  5. data/lib/shipstation/api_operations/delete.rb +10 -10
  6. data/lib/shipstation/api_operations/list.rb +11 -11
  7. data/lib/shipstation/api_operations/retrieve.rb +10 -10
  8. data/lib/shipstation/api_operations/shipment.rb +10 -10
  9. data/lib/shipstation/api_operations/update.rb +9 -9
  10. data/lib/shipstation/api_resource.rb +7 -7
  11. data/lib/shipstation/carrier.rb +11 -11
  12. data/lib/shipstation/customer.rb +5 -5
  13. data/lib/shipstation/fulfillment.rb +16 -0
  14. data/lib/shipstation/order.rb +42 -42
  15. data/lib/shipstation/product.rb +6 -6
  16. data/lib/shipstation/shipment.rb +18 -18
  17. data/lib/shipstation/store.rb +14 -14
  18. data/lib/shipstation/tag.rb +11 -11
  19. data/lib/shipstation/version.rb +3 -3
  20. data/lib/shipstation/warehouse.rb +14 -14
  21. data/lib/shipstation/webhook.rb +18 -18
  22. data/lib/shipstation.rb +97 -96
  23. data/lib/tasks/shipstation_tasks.rake +4 -4
  24. data/test/dummy/Gemfile +54 -54
  25. data/test/dummy/Gemfile.lock +191 -191
  26. data/test/dummy/README.rdoc +28 -28
  27. data/test/dummy/Rakefile +6 -6
  28. data/test/dummy/app/assets/javascripts/application.js +16 -16
  29. data/test/dummy/app/assets/stylesheets/application.css +15 -15
  30. data/test/dummy/app/controllers/application_controller.rb +5 -5
  31. data/test/dummy/app/helpers/application_helper.rb +2 -2
  32. data/test/dummy/app/views/layouts/application.html.erb +14 -14
  33. data/test/dummy/bin/bundle +3 -3
  34. data/test/dummy/bin/rails +9 -9
  35. data/test/dummy/bin/rake +9 -9
  36. data/test/dummy/bin/setup +29 -29
  37. data/test/dummy/bin/spring +17 -17
  38. data/test/dummy/config/application.rb +26 -26
  39. data/test/dummy/config/boot.rb +3 -3
  40. data/test/dummy/config/database.yml +25 -25
  41. data/test/dummy/config/environment.rb +5 -5
  42. data/test/dummy/config/environments/development.rb +41 -41
  43. data/test/dummy/config/environments/production.rb +79 -79
  44. data/test/dummy/config/environments/test.rb +42 -42
  45. data/test/dummy/config/initializers/assets.rb +11 -11
  46. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -7
  47. data/test/dummy/config/initializers/cookies_serializer.rb +3 -3
  48. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  49. data/test/dummy/config/initializers/inflections.rb +16 -16
  50. data/test/dummy/config/initializers/mime_types.rb +4 -4
  51. data/test/dummy/config/initializers/session_store.rb +3 -3
  52. data/test/dummy/config/initializers/shipstation.rb +1 -1
  53. data/test/dummy/config/initializers/wrap_parameters.rb +14 -14
  54. data/test/dummy/config/locales/en.yml +23 -23
  55. data/test/dummy/config/routes.rb +56 -56
  56. data/test/dummy/config/secrets.yml +22 -22
  57. data/test/dummy/config.ru +4 -4
  58. data/test/dummy/db/seeds.rb +7 -7
  59. data/test/dummy/public/404.html +67 -67
  60. data/test/dummy/public/422.html +67 -67
  61. data/test/dummy/public/500.html +66 -66
  62. data/test/dummy/public/favicon.ico +0 -0
  63. data/test/dummy/public/robots.txt +5 -5
  64. data/test/dummy/test/test_helper.rb +10 -10
  65. data/test/shipstation_test.rb +7 -7
  66. data/test/test_helper.rb +20 -20
  67. metadata +38 -37
data/lib/shipstation.rb CHANGED
@@ -1,96 +1,97 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rest-client'
4
-
5
- require 'shipstation/api_operations/list'
6
- require 'shipstation/api_operations/create'
7
- require 'shipstation/api_operations/retrieve'
8
- require 'shipstation/api_operations/update'
9
- require 'shipstation/api_operations/delete'
10
-
11
- require 'shipstation/api_resource'
12
- require 'shipstation/order'
13
- require 'shipstation/customer'
14
- require 'shipstation/shipment'
15
- require 'shipstation/carrier'
16
- require 'shipstation/store'
17
- require 'shipstation/warehouse'
18
- require 'shipstation/product'
19
- require 'shipstation/tag'
20
- require 'shipstation/webhook'
21
-
22
- module Shipstation
23
-
24
- API_BASE = "https://ssapi.shipstation.com/"
25
-
26
- class ShipstationError < StandardError
27
- end
28
-
29
- class AuthenticationError < ShipstationError;
30
- end
31
- class ConfigurationError < ShipstationError;
32
- end
33
- class ApiRequestError < ShipstationError
34
- attr_reader :response_code, :response_headers, :response_body
35
-
36
- def initialize(response_code:, response_headers:, response_body:)
37
- @response_code = response_code
38
- @response_headers = response_headers
39
- @response_body = response_body
40
- end
41
- end
42
-
43
- class << self
44
- def username
45
- defined? @username and @username or raise(
46
- ConfigurationError, "Shipstation username not configured"
47
- )
48
- end
49
-
50
- attr_writer :username
51
-
52
- def password
53
- defined? @password and @password or raise(
54
- ConfigurationError, "Shipstation password not configured"
55
- )
56
- end
57
-
58
- attr_writer :password
59
-
60
- def request method, resource, params = {}
61
- ss_username = params[:username] || Shipstation.username
62
- ss_password = params[:password] || Shipstation.password
63
-
64
- params.except!(:username, :password)
65
-
66
- defined? method or raise(
67
- ArgumentError, "Request method has not been specified"
68
- )
69
- defined? resource or raise(
70
- ArgumentError, "Request resource has not been specified"
71
- )
72
- if method == :get
73
- headers = {:accept => :json, content_type: :json}.merge({params: params})
74
- payload = nil
75
- else
76
- headers = {:accept => :json, content_type: :json}
77
- payload = params
78
- end
79
- RestClient::Request.new({
80
- method: method,
81
- url: API_BASE + resource,
82
- user: ss_username,
83
- password: ss_password,
84
- payload: payload ? payload.to_json : nil,
85
- headers: headers
86
- }).execute do |response, request, result|
87
- str_response = response.to_str
88
- str_response.blank? ? '' : JSON.parse(str_response)
89
- end
90
- end
91
-
92
- def datetime_format datetime
93
- datetime.strftime("%Y-%m-%d %T")
94
- end
95
- end
96
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'rest-client'
4
+
5
+ require 'shipstation/api_operations/list'
6
+ require 'shipstation/api_operations/create'
7
+ require 'shipstation/api_operations/retrieve'
8
+ require 'shipstation/api_operations/update'
9
+ require 'shipstation/api_operations/delete'
10
+
11
+ require 'shipstation/api_resource'
12
+ require 'shipstation/order'
13
+ require 'shipstation/customer'
14
+ require 'shipstation/fulfillment'
15
+ require 'shipstation/shipment'
16
+ require 'shipstation/carrier'
17
+ require 'shipstation/store'
18
+ require 'shipstation/warehouse'
19
+ require 'shipstation/product'
20
+ require 'shipstation/tag'
21
+ require 'shipstation/webhook'
22
+
23
+ module Shipstation
24
+
25
+ API_BASE = "https://ssapi.shipstation.com/"
26
+
27
+ class ShipstationError < StandardError
28
+ end
29
+
30
+ class AuthenticationError < ShipstationError;
31
+ end
32
+ class ConfigurationError < ShipstationError;
33
+ end
34
+ class ApiRequestError < ShipstationError
35
+ attr_reader :response_code, :response_headers, :response_body
36
+
37
+ def initialize(response_code:, response_headers:, response_body:)
38
+ @response_code = response_code
39
+ @response_headers = response_headers
40
+ @response_body = response_body
41
+ end
42
+ end
43
+
44
+ class << self
45
+ def username
46
+ defined? @username and @username or raise(
47
+ ConfigurationError, "Shipstation username not configured"
48
+ )
49
+ end
50
+
51
+ attr_writer :username
52
+
53
+ def password
54
+ defined? @password and @password or raise(
55
+ ConfigurationError, "Shipstation password not configured"
56
+ )
57
+ end
58
+
59
+ attr_writer :password
60
+
61
+ def request method, resource, params = {}
62
+ ss_username = params[:username] || Shipstation.username
63
+ ss_password = params[:password] || Shipstation.password
64
+
65
+ params.except!(:username, :password)
66
+
67
+ defined? method or raise(
68
+ ArgumentError, "Request method has not been specified"
69
+ )
70
+ defined? resource or raise(
71
+ ArgumentError, "Request resource has not been specified"
72
+ )
73
+ if method == :get
74
+ headers = {:accept => :json, content_type: :json}.merge({params: params})
75
+ payload = nil
76
+ else
77
+ headers = {:accept => :json, content_type: :json}
78
+ payload = params
79
+ end
80
+ RestClient::Request.new({
81
+ method: method,
82
+ url: API_BASE + resource,
83
+ user: ss_username,
84
+ password: ss_password,
85
+ payload: payload ? payload.to_json : nil,
86
+ headers: headers
87
+ }).execute do |response, request, result|
88
+ str_response = response.to_str
89
+ str_response.blank? ? '' : JSON.parse(str_response)
90
+ end
91
+ end
92
+
93
+ def datetime_format datetime
94
+ datetime.strftime("%Y-%m-%d %T")
95
+ end
96
+ end
97
+ end
@@ -1,4 +1,4 @@
1
- # desc "Explaining what the task does"
2
- # task :shipstation do
3
- # # Task goes here
4
- # end
1
+ # desc "Explaining what the task does"
2
+ # task :shipstation do
3
+ # # Task goes here
4
+ # end
data/test/dummy/Gemfile CHANGED
@@ -1,54 +1,54 @@
1
- source 'http://rubygems.org'
2
-
3
-
4
- # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5
- gem 'rails', '4.2.7'
6
- # Use sqlite3 as the database for Active Record
7
- gem 'sqlite3'
8
- # Use SCSS for stylesheets
9
- gem 'sass-rails', '~> 5.0'
10
- # Use Uglifier as compressor for JavaScript assets
11
- gem 'uglifier', '>= 1.3.0'
12
- # Use CoffeeScript for .coffee assets and views
13
- gem 'coffee-rails', '~> 4.1.0'
14
- # See https://github.com/rails/execjs#readme for more supported runtimes
15
- # gem 'therubyracer', platforms: :ruby
16
-
17
- # Use jquery as the JavaScript library
18
- gem 'jquery-rails'
19
- # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
20
- gem 'turbolinks'
21
- # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
22
- gem 'jbuilder', '~> 2.0'
23
- # bundle exec rake doc:rails generates the API under doc/api.
24
- gem 'sdoc', '~> 0.4.0', group: :doc
25
-
26
- gem 'ffi', '~> 1.9.24'
27
- gem 'sprockets', '~> 3.7.2'
28
-
29
- gem 'rest-client'
30
- gem 'shipstation'
31
-
32
-
33
- # Use ActiveModel has_secure_password
34
- # gem 'bcrypt', '~> 3.1.7'
35
-
36
- # Use Unicorn as the app server
37
- # gem 'unicorn'
38
-
39
- # Use Capistrano for deployment
40
- # gem 'capistrano-rails', group: :development
41
-
42
- group :development, :test do
43
- # Call 'byebug' anywhere in the code to stop execution and get a debugger console
44
- gem 'byebug'
45
- end
46
-
47
- group :development do
48
- # Access an IRB console on exception pages or by using <%= console %> in views
49
- gem 'web-console', '~> 2.0'
50
-
51
- # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
52
- gem 'spring'
53
- end
54
-
1
+ source 'http://rubygems.org'
2
+
3
+
4
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5
+ gem 'rails', '4.2.7'
6
+ # Use sqlite3 as the database for Active Record
7
+ gem 'sqlite3'
8
+ # Use SCSS for stylesheets
9
+ gem 'sass-rails', '~> 5.0'
10
+ # Use Uglifier as compressor for JavaScript assets
11
+ gem 'uglifier', '>= 1.3.0'
12
+ # Use CoffeeScript for .coffee assets and views
13
+ gem 'coffee-rails', '~> 4.1.0'
14
+ # See https://github.com/rails/execjs#readme for more supported runtimes
15
+ # gem 'therubyracer', platforms: :ruby
16
+
17
+ # Use jquery as the JavaScript library
18
+ gem 'jquery-rails'
19
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
20
+ gem 'turbolinks'
21
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
22
+ gem 'jbuilder', '~> 2.0'
23
+ # bundle exec rake doc:rails generates the API under doc/api.
24
+ gem 'sdoc', '~> 0.4.0', group: :doc
25
+
26
+ gem 'ffi', '~> 1.9.24'
27
+ gem 'sprockets', '~> 3.7.2'
28
+
29
+ gem 'rest-client'
30
+ gem 'shipstation'
31
+
32
+
33
+ # Use ActiveModel has_secure_password
34
+ # gem 'bcrypt', '~> 3.1.7'
35
+
36
+ # Use Unicorn as the app server
37
+ # gem 'unicorn'
38
+
39
+ # Use Capistrano for deployment
40
+ # gem 'capistrano-rails', group: :development
41
+
42
+ group :development, :test do
43
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
44
+ gem 'byebug'
45
+ end
46
+
47
+ group :development do
48
+ # Access an IRB console on exception pages or by using <%= console %> in views
49
+ gem 'web-console', '~> 2.0'
50
+
51
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
52
+ gem 'spring'
53
+ end
54
+