rms_api_ruby 0.4.0 → 0.5.0

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: cd997f991888796c31485581f894b02fdb26e1cf0a355fd1c064d8bdb625e9a9
4
- data.tar.gz: e9eb9d271154aba3e58c8009c22ed126a61fa53783cd7414afa7d5435395ee1e
3
+ metadata.gz: 7762bfa27a1e1e29ac1b420e384cfc22e67fb439fad89d23354f87bc143918a9
4
+ data.tar.gz: 3ee5168db64bac9a2150d1bff742e4c7ab1a907f24e18392ba07b1a96a43b663
5
5
  SHA512:
6
- metadata.gz: 54c1165fb6dd9c3c5c7dc2b3ccbafce5a17606168ab7652a5fb58081800356071573ea5eab6543ddd5860bbc24171c258ee6c4af57ccf71c43c8434ff531915a
7
- data.tar.gz: 452c6a1eddd87373c2bebeb650db44e5832d24a6a6605b0a20a2d4802725ea3bb371ac4c334b112096b7d757bec83542500f66f5fbfd5002125831fb90bff9e9
6
+ metadata.gz: 378ce3feab6d4eb6b0d6873feb26112a34f42eb77f87a440e1d089c862ba45d0b8a9b8aae0480e1aa3284dc4e273a1b7cf450e7e84d16efd50e6909e3c9b96b9
7
+ data.tar.gz: 2be436d5e6b29396e60987ddbe2dff210f644131613be07f540a1eb33e18bab16db1b0369a9ba2303a2c86ed4e67eaa297e72bf1b1eb5b0287dcb8b2b679cc44
@@ -1,3 +1,6 @@
1
+ ## 0.5.0 (Aug 5, 2018)
2
+ * Add RakutenPayOrder API
3
+
1
4
  ## 0.4.0 (Jul 7, 2018)
2
5
  * Add Product API and Navigation API
3
6
 
@@ -1,9 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rms_api_ruby (0.4.0)
4
+ rms_api_ruby (0.5.0)
5
5
  activesupport
6
+ faraday
7
+ faraday_middleware
6
8
  hashie
9
+ multi_xml
7
10
  savon (~> 2.12.0)
8
11
  waterfall (~> 1.2.0)
9
12
 
@@ -28,6 +31,10 @@ GEM
28
31
  crack (0.4.3)
29
32
  safe_yaml (~> 1.0.0)
30
33
  diff-lcs (1.3)
34
+ faraday (0.15.2)
35
+ multipart-post (>= 1.2, < 3)
36
+ faraday_middleware (0.12.2)
37
+ faraday (>= 0.7.4, < 1.0)
31
38
  gyoku (1.3.1)
32
39
  builder (>= 2.1.2)
33
40
  hashdiff (0.3.7)
@@ -41,7 +48,9 @@ GEM
41
48
  method_source (0.9.0)
42
49
  mini_portile2 (2.3.0)
43
50
  minitest (5.11.3)
44
- nokogiri (1.8.3)
51
+ multi_xml (0.6.0)
52
+ multipart-post (2.0.0)
53
+ nokogiri (1.8.4)
45
54
  mini_portile2 (~> 2.3.0)
46
55
  nori (2.6.0)
47
56
  parallel (1.12.1)
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![CircleCI](https://circleci.com/gh/Kaicoh/rms_api_ruby/tree/master.svg?style=svg)](https://circleci.com/gh/Kaicoh/rms_api_ruby/tree/master)
5
5
 
6
6
  RmsApiRuby is a ruby gem for the RMS(Rakuten Marchant Service) Web API. By default all API calls will return [Hashie::Mash](https://github.com/intridea/hashie/tree/v1.2.0) objects.
7
- At this time this gem supports OrderAPI, InventoryAPI, ItemAPI, ProductAPI and NavigationAPI.
7
+ At this time the APIs this gem supports are as follows.
8
8
 
9
9
  Support
10
10
  - OrderAPI
@@ -12,6 +12,7 @@ Support
12
12
  - ItemAPI
13
13
  - ProductAPI
14
14
  - NavigationAPI
15
+ - RakutenPayOrderAPI
15
16
 
16
17
  Not Support yet
17
18
  - CabinetAPI
@@ -19,7 +20,6 @@ Not Support yet
19
20
  - CouponAPI
20
21
  - ShopManagimentAPI
21
22
  - System Event Notification Service
22
- - RakutenPayOrderAPI
23
23
  - PaymentAPI
24
24
 
25
25
  ## Installation
@@ -63,6 +63,7 @@ RmsApiRuby.configure do |config|
63
63
  config.item_api_version = 'Item API version' # default 1.0
64
64
  config.product_api_version = 'Product API version' # default 2.0
65
65
  config.navigation_api_version = 'Navigation API version' # default 1.0
66
+ config.rakuten_pay_order_api_version = 'RakutenPayOrder API version' # default 2.0
66
67
  end
67
68
  ```
68
69
 
@@ -72,6 +73,7 @@ end
72
73
  - [ItemAPI](docs/item_api.md)
73
74
  - [ProductAPI](docs/product_api.md)
74
75
  - [NavigationAPI](docs/navigation_api.md)
76
+ - [RakutenPayOrderAPI](docs/rakuten_pay_order_api.md)
75
77
 
76
78
  ## Contributing
77
79
 
@@ -0,0 +1,17 @@
1
+ ## RakutenPayOrderAPI
2
+
3
+ ### GetOrder
4
+
5
+ ```ruby
6
+ args = {
7
+ order_number_list: ['Rakuten order number you want'],
8
+ }
9
+ response = RmsApiRuby::RakutenPayOrder.get_order(args)
10
+ # => #<Hashie::Mash>
11
+
12
+ response.keys
13
+ # => ["message_model_list", "order_model_list"]
14
+
15
+ rakuten_order = response.order_model
16
+ # => #<Hashie::Array>
17
+ ```
@@ -1,7 +1,9 @@
1
1
  require 'active_support'
2
2
  require 'active_support/core_ext'
3
3
  require 'waterfall'
4
- require 'pry'
4
+ require 'hashie'
5
+ require 'faraday'
6
+ require 'faraday_middleware'
5
7
  require "rms_api_ruby/version"
6
8
  require 'rms_api_ruby/config'
7
9
 
@@ -10,15 +12,17 @@ module RmsApiRuby
10
12
  ServerError = Class.new(Error)
11
13
  AuthenticationError = Class.new(Error)
12
14
 
13
- autoload :Authentication, 'rms_api_ruby/authentication'
14
- autoload :Chain, 'rms_api_ruby/chain'
15
- autoload :Order, 'rms_api_ruby/order'
16
- autoload :Orders, 'rms_api_ruby/orders'
17
- autoload :Inventory, 'rms_api_ruby/inventory'
18
- autoload :Item, 'rms_api_ruby/item'
19
- autoload :Items, 'rms_api_ruby/items'
20
- autoload :Product, 'rms_api_ruby/product'
21
- autoload :Navigation, 'rms_api_ruby/navigation'
15
+ autoload :Authentication, 'rms_api_ruby/authentication'
16
+ autoload :Middleware, 'rms_api_ruby/middleware'
17
+ autoload :Chain, 'rms_api_ruby/chain'
18
+ autoload :Order, 'rms_api_ruby/order'
19
+ autoload :Orders, 'rms_api_ruby/orders'
20
+ autoload :Inventory, 'rms_api_ruby/inventory'
21
+ autoload :Item, 'rms_api_ruby/item'
22
+ autoload :Items, 'rms_api_ruby/items'
23
+ autoload :Product, 'rms_api_ruby/product'
24
+ autoload :Navigation, 'rms_api_ruby/navigation'
25
+ autoload :RakutenPayOrder, 'rms_api_ruby/rakuten_pay_order'
22
26
 
23
27
  def self.root
24
28
  File.dirname __dir__
@@ -90,6 +90,7 @@ module RmsApiRuby
90
90
  option :item_api_version, default: '1.0'
91
91
  option :product_api_version, default: '2.0'
92
92
  option :navigation_api_version, default: '1.0'
93
+ option :rakuten_pay_order_api_version, default: '2.0'
93
94
 
94
95
  def options
95
96
  self.class.options
@@ -0,0 +1,16 @@
1
+ module RmsApiRuby
2
+ class Middleware
3
+ autoload :Camelcase, 'rms_api_ruby/middleware/camelcase'
4
+ autoload :Snakecase, 'rms_api_ruby/middleware/snakecase'
5
+ autoload :ParseMash, 'rms_api_ruby/middleware/parse_mash'
6
+
7
+ if Faraday::Middleware.respond_to? :register_middleware
8
+ Faraday::Request.register_middleware \
9
+ camelcase: -> { Camelcase }
10
+
11
+ Faraday::Response.register_middleware \
12
+ snakecase: -> { Snakecase },
13
+ parse_mash: -> { ParseMash }
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ require 'rms_api_ruby/utility/hash_keys_camelizable'
2
+
3
+ module RmsApiRuby
4
+ class Middleware
5
+ class Camelcase < Faraday::Middleware
6
+ include RmsApiRuby::HashKeysCamelizable
7
+
8
+ def call(env)
9
+ env[:body] = camelize_keys(env[:body], :lower)
10
+ @app.call env
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ require 'hashie/mash'
2
+
3
+ module RmsApiRuby
4
+ class Middleware
5
+ class ParseMash < Faraday::Response::Middleware
6
+ def on_complete(env)
7
+ env[:body] = Hashie::Mash.new(env[:body])
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ require 'rms_api_ruby/utility/hash_keys_underscorable'
2
+
3
+ module RmsApiRuby
4
+ class Middleware
5
+ class Snakecase < Faraday::Response::Middleware
6
+ include RmsApiRuby::HashKeysUnderscorable
7
+
8
+ def on_complete(env)
9
+ env[:body] = snake_keys env[:body]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,59 @@
1
+ require 'rms_api_ruby/middleware'
2
+
3
+ module RmsApiRuby
4
+ class RakutenPayOrder
5
+ BASE_URL = 'https://api.rms.rakuten.co.jp'.freeze
6
+ API_METHODS = %w[
7
+ get_order
8
+ search_order
9
+ confirm_order
10
+ update_order_shipping
11
+ update_order_delivery
12
+ update_order_orderer
13
+ update_order_remarks
14
+ update_order_sender
15
+ update_order_memo
16
+ get_payment
17
+ cancel_order
18
+ get_sub_status_list
19
+ update_order_sub_status
20
+ ].freeze
21
+
22
+ class << self
23
+ API_METHODS.each do |api_method|
24
+ define_method api_method do |args = nil|
25
+ connection.post do |req|
26
+ req.url endpoint(api_method)
27
+ req.headers['Content-Type'] = 'application/json; charset=utf-8'
28
+ req.headers['Authorization'] = RmsApiRuby::Authentication.key
29
+ req.body = args
30
+ end.try(:body)
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def connection
37
+ Faraday.new(url: BASE_URL) do |faraday|
38
+ faraday.request :camelcase
39
+ faraday.request :url_encoded
40
+ faraday.request :json
41
+
42
+ faraday.response :logger
43
+ faraday.response :parse_mash
44
+ faraday.response :snakecase
45
+ faraday.response :xml, content_type: /\bxml$/
46
+ faraday.response :json, content_type: /\bjson$/
47
+
48
+ faraday.use :instrumentation
49
+ faraday.adapter Faraday.default_adapter
50
+ end
51
+ end
52
+
53
+ def endpoint(api_method)
54
+ "/es/#{RmsApiRuby.configuration.rakuten_pay_order_api_version}" \
55
+ "/order/#{api_method.to_s.camelize(:lower)}/"
56
+ end
57
+ end
58
+ end
59
+ end
@@ -3,14 +3,17 @@ require 'active_support/core_ext'
3
3
  module RmsApiRuby
4
4
  module HashKeysCamelizable
5
5
  def camelize_keys(hash, first_letter = :upper)
6
- return nil if hash.nil?
7
- hash.each_with_object({}) do |(key, val), acc|
8
- if val.is_a?(Array)
9
- val = val.map { |v| to_camel_keys(v, first_letter) }
10
- elsif val.is_a?(Hash)
11
- val = camelize_keys(val, first_letter)
6
+ if hash.respond_to? :each_with_object
7
+ hash.each_with_object({}) do |(key, val), acc|
8
+ if val.is_a?(Array)
9
+ val = val.map { |v| to_camel_keys(v, first_letter) }
10
+ elsif val.is_a?(Hash)
11
+ val = camelize_keys(val, first_letter)
12
+ end
13
+ acc[camel_key(key, first_letter)] = val
12
14
  end
13
- acc[camel_key(key, first_letter)] = val
15
+ else
16
+ hash
14
17
  end
15
18
  end
16
19
 
@@ -3,14 +3,17 @@ require 'active_support/core_ext'
3
3
  module RmsApiRuby
4
4
  module HashKeysUnderscorable
5
5
  def snake_keys(hash)
6
- return nil if hash.nil?
7
- hash.each_with_object({}) do |(key, val), acc|
8
- if val.is_a?(Array)
9
- val = val.map { |v| to_snake_keys(v) }
10
- elsif val.is_a?(Hash)
11
- val = snake_keys(val)
6
+ if hash.respond_to? :each_with_object
7
+ hash.each_with_object({}) do |(key, val), acc|
8
+ if val.is_a?(Array)
9
+ val = val.map { |v| to_snake_keys(v) }
10
+ elsif val.is_a?(Hash)
11
+ val = snake_keys(val)
12
+ end
13
+ acc[snake_key(key)] = val
12
14
  end
13
- acc[snake_key(key)] = val
15
+ else
16
+ hash
14
17
  end
15
18
  end
16
19
 
@@ -1,3 +1,3 @@
1
1
  module RmsApiRuby
2
- VERSION = "0.4.0".freeze
2
+ VERSION = "0.5.0".freeze
3
3
  end
@@ -35,7 +35,10 @@ Gem::Specification.new do |spec|
35
35
  spec.require_paths = ["lib"]
36
36
 
37
37
  spec.add_dependency 'activesupport'
38
+ spec.add_dependency 'faraday'
39
+ spec.add_dependency 'faraday_middleware'
38
40
  spec.add_dependency 'hashie'
41
+ spec.add_dependency 'multi_xml'
39
42
  spec.add_dependency 'savon', '~> 2.12.0'
40
43
  spec.add_dependency 'waterfall', '~> 1.2.0'
41
44
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rms_api_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaicoh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-06 00:00:00.000000000 Z
11
+ date: 2018-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday_middleware
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: hashie
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +66,20 @@ dependencies:
38
66
  - - ">="
39
67
  - !ruby/object:Gem::Version
40
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: multi_xml
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
41
83
  - !ruby/object:Gem::Dependency
42
84
  name: savon
43
85
  requirement: !ruby/object:Gem::Requirement
@@ -190,6 +232,7 @@ files:
190
232
  - docs/navigation_api.md
191
233
  - docs/order_api.md
192
234
  - docs/product_api.md
235
+ - docs/rakuten_pay_order_api.md
193
236
  - lib/rms_api_ruby.rb
194
237
  - lib/rms_api_ruby/authentication.rb
195
238
  - lib/rms_api_ruby/chain.rb
@@ -206,6 +249,10 @@ files:
206
249
  - lib/rms_api_ruby/item/search.rb
207
250
  - lib/rms_api_ruby/item/update.rb
208
251
  - lib/rms_api_ruby/items.rb
252
+ - lib/rms_api_ruby/middleware.rb
253
+ - lib/rms_api_ruby/middleware/camelcase.rb
254
+ - lib/rms_api_ruby/middleware/parse_mash.rb
255
+ - lib/rms_api_ruby/middleware/snakecase.rb
209
256
  - lib/rms_api_ruby/navigation.rb
210
257
  - lib/rms_api_ruby/navigation/base.rb
211
258
  - lib/rms_api_ruby/navigation/genre_get.rb
@@ -214,6 +261,7 @@ files:
214
261
  - lib/rms_api_ruby/order.rb
215
262
  - lib/rms_api_ruby/orders.rb
216
263
  - lib/rms_api_ruby/product.rb
264
+ - lib/rms_api_ruby/rakuten_pay_order.rb
217
265
  - lib/rms_api_ruby/rest_api/base.rb
218
266
  - lib/rms_api_ruby/soap_api.rb
219
267
  - lib/rms_api_ruby/soap_api/client.rb