tradenity 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +89 -77
  4. data/lib/tradenity/api_client.rb +408 -0
  5. data/lib/tradenity/api_error.rb +36 -0
  6. data/lib/tradenity/configuration.rb +205 -0
  7. data/lib/tradenity/exceptions.rb +5 -0
  8. data/lib/tradenity/rails/railtie.rb +20 -20
  9. data/lib/tradenity/resources/address.rb +729 -0
  10. data/lib/tradenity/resources/braintree_gateway.rb +804 -0
  11. data/lib/tradenity/resources/brand.rb +732 -0
  12. data/lib/tradenity/resources/cancel_operation.rb +675 -0
  13. data/lib/tradenity/resources/cart_settings.rb +219 -0
  14. data/lib/tradenity/resources/cash_on_delivery_payment.rb +746 -0
  15. data/lib/tradenity/resources/category.rb +763 -0
  16. data/lib/tradenity/resources/collection.rb +734 -0
  17. data/lib/tradenity/resources/contact_info.rb +306 -0
  18. data/lib/tradenity/resources/countries_geo_zone.rb +739 -0
  19. data/lib/tradenity/resources/country.rb +803 -0
  20. data/lib/tradenity/resources/coupon.rb +454 -0
  21. data/lib/tradenity/resources/credit_card_payment.rb +803 -0
  22. data/lib/tradenity/resources/currency.rb +762 -0
  23. data/lib/tradenity/resources/customer.rb +816 -0
  24. data/lib/tradenity/resources/customer_group.rb +723 -0
  25. data/lib/tradenity/resources/dimensions.rb +263 -0
  26. data/lib/tradenity/resources/discount_coupon.rb +811 -0
  27. data/lib/tradenity/resources/discount_promotion.rb +784 -0
  28. data/lib/tradenity/resources/fixed_rate_shipping.rb +837 -0
  29. data/lib/tradenity/resources/free_item_coupon.rb +793 -0
  30. data/lib/tradenity/resources/free_shipping.rb +806 -0
  31. data/lib/tradenity/resources/free_shipping_coupon.rb +788 -0
  32. data/lib/tradenity/resources/free_shipping_promotion.rb +744 -0
  33. data/lib/tradenity/resources/gateway.rb +435 -0
  34. data/lib/tradenity/resources/general_settings.rb +206 -0
  35. data/lib/tradenity/resources/geo_zone.rb +406 -0
  36. data/lib/tradenity/resources/instance_meta.rb +182 -0
  37. data/lib/tradenity/resources/inventory_settings.rb +197 -0
  38. data/lib/tradenity/resources/items_selector.rb +270 -0
  39. data/lib/tradenity/resources/line_item.rb +347 -0
  40. data/lib/tradenity/resources/mail_server_settings.rb +221 -0
  41. data/lib/tradenity/resources/measurement_settings.rb +253 -0
  42. data/lib/tradenity/resources/option.rb +787 -0
  43. data/lib/tradenity/resources/option_set.rb +734 -0
  44. data/lib/tradenity/resources/option_value.rb +680 -0
  45. data/lib/tradenity/resources/order.rb +929 -0
  46. data/lib/tradenity/resources/order_line_item.rb +777 -0
  47. data/lib/tradenity/resources/paging.rb +38 -0
  48. data/lib/tradenity/resources/payment.rb +429 -0
  49. data/lib/tradenity/resources/payment_card.rb +847 -0
  50. data/lib/tradenity/resources/payment_settings.rb +201 -0
  51. data/lib/tradenity/resources/payment_source.rb +392 -0
  52. data/lib/tradenity/resources/payment_token.rb +723 -0
  53. data/lib/tradenity/resources/payment_transaction.rb +740 -0
  54. data/lib/tradenity/resources/photo.rb +341 -0
  55. data/lib/tradenity/resources/product.rb +1156 -0
  56. data/lib/tradenity/resources/promotion.rb +427 -0
  57. data/lib/tradenity/resources/refund_operation.rb +358 -0
  58. data/lib/tradenity/resources/refund_transaction.rb +730 -0
  59. data/lib/tradenity/resources/return_line_item.rb +781 -0
  60. data/lib/tradenity/resources/return_operation.rb +686 -0
  61. data/lib/tradenity/resources/return_settings.rb +255 -0
  62. data/lib/tradenity/resources/shipping_method.rb +530 -0
  63. data/lib/tradenity/resources/shopping_cart.rb +647 -0
  64. data/lib/tradenity/resources/state.rb +675 -0
  65. data/lib/tradenity/resources/states_geo_zone.rb +748 -0
  66. data/lib/tradenity/resources/store_credit.rb +686 -0
  67. data/lib/tradenity/resources/store_credit_payment.rb +764 -0
  68. data/lib/tradenity/resources/store_credit_transaction.rb +730 -0
  69. data/lib/tradenity/resources/store_profile.rb +532 -0
  70. data/lib/tradenity/resources/stripe_gateway.rb +804 -0
  71. data/lib/tradenity/resources/table_rate_rule.rb +712 -0
  72. data/lib/tradenity/resources/table_rate_shipping.rb +834 -0
  73. data/lib/tradenity/resources/tax_class.rb +723 -0
  74. data/lib/tradenity/resources/tax_rate.rb +845 -0
  75. data/lib/tradenity/resources/tax_settings.rb +231 -0
  76. data/lib/tradenity/resources/test_gateway.rb +804 -0
  77. data/lib/tradenity/resources/transaction.rb +523 -0
  78. data/lib/tradenity/resources/utils.rb +7 -0
  79. data/lib/tradenity/resources/variant.rb +877 -0
  80. data/lib/tradenity/resources/web_hooks.rb +262 -0
  81. data/lib/tradenity/resources/weight.rb +235 -0
  82. data/lib/tradenity/resources/wish_list.rb +686 -0
  83. data/lib/tradenity/resources/zip_codes_geo_zone.rb +755 -0
  84. data/lib/tradenity/token_holder.rb +22 -0
  85. data/lib/tradenity/version.rb +13 -3
  86. data/lib/tradenity.rb +117 -7
  87. data/tradenity.gemspec +35 -30
  88. metadata +200 -34
  89. data/lib/tradenity/api.rb +0 -17
  90. data/lib/tradenity/error/exceptions.rb +0 -52
  91. data/lib/tradenity/error/message.rb +0 -38
  92. data/lib/tradenity/http/client.rb +0 -130
  93. data/lib/tradenity/model/base.rb +0 -100
  94. data/lib/tradenity/model/entities.rb +0 -390
  95. data/lib/tradenity/model/paging.rb +0 -23
@@ -0,0 +1,205 @@
1
+ =begin
2
+ #Tradenity API
3
+
4
+ #Tradenity eCommerce Rest API
5
+
6
+ Contact: support@tradenity.com
7
+ Generated by: https://github.com/tradenity
8
+
9
+ =end
10
+
11
+ require 'uri'
12
+
13
+ module Tradenity
14
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+
25
+ # Defines session token holder
26
+ attr_accessor :session_token_holder
27
+
28
+ # Defines API keys used with API Key authentications.
29
+ #
30
+ # @return [Hash] key: parameter name, value: parameter value (API key)
31
+ #
32
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
33
+ # config.api_key['api_key'] = 'xxx'
34
+ attr_accessor :api_key
35
+
36
+ # Defines API key prefixes used with API Key authentications.
37
+ #
38
+ # @return [Hash] key: parameter name, value: API key prefix
39
+ #
40
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
41
+ # config.api_key_prefix['api_key'] = 'Token'
42
+ attr_accessor :api_key_prefix
43
+
44
+ # Defines the username used with HTTP basic authentication.
45
+ #
46
+ # @return [String]
47
+ attr_accessor :username
48
+
49
+ # Defines the password used with HTTP basic authentication.
50
+ #
51
+ # @return [String]
52
+ attr_accessor :password
53
+
54
+ # Defines the access token (Bearer) used with OAuth2.
55
+ attr_accessor :access_token
56
+
57
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
58
+ # details will be logged with `logger.debug` (see the `logger` attribute).
59
+ # Default to false.
60
+ #
61
+ # @return [true, false]
62
+ attr_accessor :debugging
63
+
64
+ # Defines the logger used for debugging.
65
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
66
+ #
67
+ # @return [#debug]
68
+ attr_accessor :logger
69
+
70
+ # Defines the temporary folder to store downloaded files
71
+ # (for API endpoints that have file response).
72
+ # Default to use `Tempfile`.
73
+ #
74
+ # @return [String]
75
+ attr_accessor :temp_folder_path
76
+
77
+ # The time limit for HTTP request in seconds.
78
+ # Default to 0 (never times out).
79
+ attr_accessor :timeout
80
+
81
+ # Set this to false to skip client side validation in the operation.
82
+ # Default to true.
83
+ # @return [true, false]
84
+ attr_accessor :client_side_validation
85
+
86
+ ### TLS/SSL setting
87
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
88
+ # Default to true.
89
+ #
90
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
91
+ #
92
+ # @return [true, false]
93
+ attr_accessor :verify_ssl
94
+
95
+ ### TLS/SSL setting
96
+ # Set this to false to skip verifying SSL host name
97
+ # Default to true.
98
+ #
99
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
100
+ #
101
+ # @return [true, false]
102
+ attr_accessor :verify_ssl_host
103
+
104
+ ### TLS/SSL setting
105
+ # Set this to customize the certificate file to verify the peer.
106
+ #
107
+ # @return [String] the path to the certificate file
108
+ #
109
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
110
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
111
+ attr_accessor :ssl_ca_cert
112
+
113
+ ### TLS/SSL setting
114
+ # Client certificate file (for client certificate)
115
+ attr_accessor :cert_file
116
+
117
+ ### TLS/SSL setting
118
+ # Client private key file (for client certificate)
119
+ attr_accessor :key_file
120
+
121
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
122
+ # Default to nil.
123
+ #
124
+ # @see The params_encoding option of Ethon. Related source code:
125
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
126
+ attr_accessor :params_encoding
127
+
128
+ attr_accessor :inject_format
129
+
130
+ attr_accessor :force_ending_format
131
+
132
+ def initialize
133
+ @scheme = 'https'
134
+ @host = 'api.tradenity.com'
135
+ @base_path = '/v1'
136
+ @api_key = {}
137
+ @api_key_prefix = {}
138
+ @timeout = 0
139
+ @client_side_validation = true
140
+ @verify_ssl = true
141
+ @verify_ssl_host = true
142
+ @params_encoding = nil
143
+ @cert_file = nil
144
+ @key_file = nil
145
+ @debugging = false
146
+ @inject_format = false
147
+ @force_ending_format = false
148
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
149
+ @session_token_holder = SessionTokenHolder.new
150
+
151
+ yield(self) if block_given?
152
+ end
153
+
154
+ # The default Configuration object.
155
+ def self.default
156
+ @@default ||= Configuration.new
157
+ end
158
+
159
+ def configure
160
+ yield(self) if block_given?
161
+ end
162
+
163
+ def scheme=(scheme)
164
+ # remove :// from scheme
165
+ @scheme = scheme.sub(/:\/\//, '')
166
+ end
167
+
168
+ def host=(host)
169
+ # remove http(s):// and anything after a slash
170
+ @host = host.sub(/https?:\/\//, '').split('/').first
171
+ end
172
+
173
+ def base_path=(base_path)
174
+ # Add leading and trailing slashes to base_path
175
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
176
+ @base_path = '' if @base_path == '/'
177
+ end
178
+
179
+ def base_url
180
+ url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
181
+ URI.encode(url)
182
+ end
183
+
184
+ # Gets API key (with prefix if set).
185
+ # @param [String] param_name the parameter name of API key auth
186
+ def api_key_with_prefix(param_name)
187
+ if @api_key_prefix[param_name]
188
+ "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
189
+ else
190
+ @api_key[param_name]
191
+ end
192
+ end
193
+
194
+ # Gets Basic Auth token string
195
+ def basic_auth_token
196
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
197
+ end
198
+
199
+ # Returns Auth Settings hash for api client.
200
+ def auth_settings
201
+ {
202
+ }
203
+ end
204
+ end
205
+ end
@@ -0,0 +1,5 @@
1
+ module Tradenity
2
+ class SessionExpiredException
3
+
4
+ end
5
+ end
@@ -1,21 +1,21 @@
1
- module Tradenity
2
- module RailsSupport
3
- def adjust_tradenity_session
4
- HttpClient.get_instance.current_session(session)
5
- end
6
- end
7
-
8
- class Railtie < ::Rails::Railtie
9
- initializer 'tradenity.configure_controllers' do |app|
10
-
11
- ActiveSupport.on_load :action_controller do
12
-
13
- include Tradenity
14
- include Tradenity::RailsSupport
15
-
16
- before_filter :adjust_tradenity_session
17
-
18
- end
19
- end
20
- end
1
+ module Tradenity
2
+ module RailsSupport
3
+ def adjust_session
4
+ Configuration.default.session_token_holder.session = session
5
+ end
6
+ end
7
+
8
+ class Railtie < ::Rails::Railtie
9
+ initializer 'tradenity.configure_controllers' do |app|
10
+
11
+ ActiveSupport.on_load :action_controller do
12
+
13
+ include Tradenity
14
+ include Tradenity::RailsSupport
15
+
16
+ before_filter :adjust_session
17
+
18
+ end
19
+ end
20
+ end
21
21
  end