rms_api_ruby 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 275407ab24c83f7720bf376916d9ce4ad44898ca4ec8ec989c054a2c9a1936d9
4
+ data.tar.gz: d831ece875c47de36f6cbaac6e717edde45f616e682a52de0a934bdbe55f6784
5
+ SHA512:
6
+ metadata.gz: 4852d22b9899f2ba4799bb5b3e4842bbcde1768cc57c8cf2ecde20834d6a3342d78b2a72fe3c2b8829b84523e83f31e75ac59d2587dfa44181aca0bf951219b0
7
+ data.tar.gz: 89a0b5b8276496c891aa1340ea32fde141aa97708537791fc55b93543d8017ca57e85782fc73a69109b1b84e73468d22c8668c5f3d47101b0b60057fff6ca7e4
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,79 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ Include:
4
+ - Rakefile
5
+ Exclude:
6
+ - rms_api_ruby.gemspec
7
+ - .*/**/*
8
+
9
+ # Limit lines to 80 characters.
10
+ LineLength:
11
+ Max: 90
12
+
13
+ ClassLength:
14
+ Enabled: false
15
+
16
+ ModuleLength:
17
+ Enabled: false
18
+
19
+ # Avoid methods longer than 30 lines of code
20
+ MethodLength:
21
+ CountComments: false # count full line comments?
22
+ Max: 87
23
+
24
+ # Avoid single-line methods.
25
+ SingleLineMethods:
26
+ AllowIfMethodIsEmpty: true
27
+
28
+ StringLiterals:
29
+ Enabled: false
30
+
31
+ GlobalVars:
32
+ Enabled: false # We use them Redis + StatsD (though maybe we shouldn't?)
33
+
34
+ # Wants underscores in all large numbers. Pain in the ass for things like
35
+ # unix timestamps.
36
+ NumericLiterals:
37
+ Enabled: false
38
+
39
+ # Wants you to use the same argument names for every reduce. This seems kinda
40
+ # naff compared to naming them semantically
41
+ SingleLineBlockParams:
42
+ Enabled: false
43
+
44
+ Style/SignalException:
45
+ EnforcedStyle: 'only_raise'
46
+
47
+ # Use trailing rather than leading dots on multi-line call chains
48
+ Layout/DotPosition:
49
+ EnforcedStyle: trailing
50
+
51
+ # Allow non-ASCII characters (e.g. £) in comments
52
+ Style/AsciiComments:
53
+ Enabled: false
54
+
55
+ # Allow method names beginning with capital letters to match Salesforce conventions
56
+ Naming/MethodName:
57
+ Enabled: false
58
+
59
+ Metrics/BlockLength:
60
+ Exclude:
61
+ - spec/**/*
62
+ - restforce.gemspec
63
+
64
+ Naming/AccessorMethodName:
65
+ Enabled: false
66
+
67
+ Naming/FileName:
68
+ Exclude:
69
+ - Gemfile
70
+ - Guardfile
71
+
72
+ Lint/UriEscapeUnescape:
73
+ Enabled: false
74
+
75
+ Documentation:
76
+ Enabled: false
77
+
78
+ Layout/MultilineMethodCallIndentation:
79
+ EnforcedStyle: indented
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.16.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at sumireminami@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in rms_api_ruby.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,97 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rms_api_ruby (0.1.0)
5
+ activesupport
6
+ hashie
7
+ savon (~> 2.12.0)
8
+ waterfall (~> 1.2.0)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activesupport (5.2.0)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (>= 0.7, < 2)
16
+ minitest (~> 5.1)
17
+ tzinfo (~> 1.1)
18
+ akami (1.3.1)
19
+ gyoku (>= 0.4.0)
20
+ nokogiri
21
+ ast (2.4.0)
22
+ builder (3.2.3)
23
+ concurrent-ruby (1.0.5)
24
+ diff-lcs (1.3)
25
+ gyoku (1.3.1)
26
+ builder (>= 2.1.2)
27
+ hashie (3.5.7)
28
+ httpi (2.4.3)
29
+ rack
30
+ socksify
31
+ i18n (1.0.1)
32
+ concurrent-ruby (~> 1.0)
33
+ jaro_winkler (1.5.1)
34
+ mini_portile2 (2.3.0)
35
+ minitest (5.11.3)
36
+ nokogiri (1.8.2)
37
+ mini_portile2 (~> 2.3.0)
38
+ nori (2.6.0)
39
+ parallel (1.12.1)
40
+ parser (2.5.1.0)
41
+ ast (~> 2.4.0)
42
+ powerpack (0.1.1)
43
+ rack (2.0.5)
44
+ rainbow (3.0.0)
45
+ rake (10.5.0)
46
+ rspec (3.7.0)
47
+ rspec-core (~> 3.7.0)
48
+ rspec-expectations (~> 3.7.0)
49
+ rspec-mocks (~> 3.7.0)
50
+ rspec-core (3.7.1)
51
+ rspec-support (~> 3.7.0)
52
+ rspec-expectations (3.7.0)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.7.0)
55
+ rspec-mocks (3.7.0)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.7.0)
58
+ rspec-support (3.7.1)
59
+ rubocop (0.57.1)
60
+ jaro_winkler (~> 1.5.1)
61
+ parallel (~> 1.10)
62
+ parser (>= 2.5)
63
+ powerpack (~> 0.1)
64
+ rainbow (>= 2.2.2, < 4.0)
65
+ ruby-progressbar (~> 1.7)
66
+ unicode-display_width (~> 1.0, >= 1.0.1)
67
+ ruby-progressbar (1.9.0)
68
+ savon (2.12.0)
69
+ akami (~> 1.2)
70
+ builder (>= 2.1.2)
71
+ gyoku (~> 1.2)
72
+ httpi (~> 2.3)
73
+ nokogiri (>= 1.8.1)
74
+ nori (~> 2.4)
75
+ wasabi (~> 3.4)
76
+ socksify (1.7.1)
77
+ thread_safe (0.3.6)
78
+ tzinfo (1.2.5)
79
+ thread_safe (~> 0.1)
80
+ unicode-display_width (1.4.0)
81
+ wasabi (3.5.0)
82
+ httpi (~> 2.0)
83
+ nokogiri (>= 1.4.2)
84
+ waterfall (1.2.0)
85
+
86
+ PLATFORMS
87
+ ruby
88
+
89
+ DEPENDENCIES
90
+ bundler (~> 1.16)
91
+ rake (~> 10.0)
92
+ rms_api_ruby!
93
+ rspec (~> 3.0)
94
+ rubocop (~> 0.57.1)
95
+
96
+ BUNDLED WITH
97
+ 1.16.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Kaicoh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # RmsApiRuby
2
+
3
+ RmsApiRuby is a ruby gem for the RMS(Rakuten Marchant Service) Web API. At this time this gem supports OrderAPI only.By default all API calls will return [Hashie::Mash](https://github.com/intridea/hashie/tree/v1.2.0) objects.
4
+
5
+ Support
6
+ - OrderAPI
7
+
8
+ Not Support yet
9
+ - ItemAPI
10
+ - ProductAPI
11
+ - CabinetAPI
12
+ - NavigationAPI
13
+ - CategoryAPI
14
+ - CouponAPI
15
+ - ShopManagimentAPI
16
+ - InventoryAPI
17
+ - System Event Notification Service
18
+ - RakutenPayOrderAPI
19
+ - PaymentAPI
20
+
21
+ ## Installation
22
+
23
+ Add this line to your application's Gemfile:
24
+
25
+ ```ruby
26
+ gem 'rms_api_ruby'
27
+ ```
28
+
29
+ And then execute:
30
+
31
+ $ bundle
32
+
33
+ Or install it yourself as:
34
+
35
+ $ gem install rms_api_ruby
36
+
37
+ ## Usage
38
+
39
+ ### Configuration
40
+
41
+ You can set the service secret, license key, shop url in environment variables:
42
+
43
+ ```ruby
44
+ export RMS_API_SERVICE_SECRET="Your RMS service secret"
45
+ export RMS_API_LICENSE_KEY="Your RMS license key"
46
+ export RMS_API_SHOP_URL="Your RMS shop url"
47
+ ```
48
+
49
+ Or can set any of the options via this way
50
+
51
+ ```ruby
52
+ RmsApiRuby.configure do |config|
53
+ config.service_secret = 'Your RMS service secret'
54
+ config.license_key = 'Your RMS license key'
55
+ config.shop_url = 'Your RMS shop url'
56
+ config.version = 'RMS API version' # default 1.0
57
+ config.user_name = 'user name' # default 'rms_api_ruby'
58
+ end
59
+ ```
60
+
61
+ ### Example
62
+
63
+ #### GetOrder
64
+
65
+ ```ruby
66
+ args = {
67
+ is_order_number_only_flag: false,
68
+ order_number: ['Rakuten order number you want'],
69
+ }
70
+ response = RmsApiRuby::Orders.get_order(args)
71
+ # => #<Hashie::Mash>
72
+
73
+ response.error_code
74
+ # => 'N00-000'
75
+
76
+ response.message
77
+ # => '正常終了'
78
+
79
+ rakuten_order = response.order_model
80
+ # => #<Hashie::Mash>
81
+ ```
82
+
83
+ #### ChangeStatus
84
+
85
+ ```ruby
86
+ response = RmsApiRuby::Orders.get_request_id
87
+ # => #<Hashie::Mash>
88
+
89
+ response.error_code
90
+ # => 'N00-000'
91
+
92
+ response.message
93
+ # => '正常終了'
94
+
95
+ request_id = response.request_id
96
+ # => 'XXXXXXXXXX'
97
+
98
+ args = {
99
+ request_id: request_id,
100
+ order_status_model: [
101
+ {
102
+ order_number: ['Rakuten order number you want to change status'],
103
+ status_name: '発送後入金待ち'
104
+ }
105
+ ]
106
+ }
107
+
108
+ response = RmsApiRuby::Orders.change_status(args)
109
+ # => #<Hashie::Mash>
110
+
111
+ response.error_code
112
+ # => 'N00-000'
113
+
114
+ response.message
115
+ # => '正常終了'
116
+
117
+ ```
118
+
119
+ ## Development
120
+
121
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
122
+
123
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
124
+
125
+ ## Contributing
126
+
127
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Kaicoh/rms_api_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
128
+
129
+ ## License
130
+
131
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
132
+
133
+ ## Code of Conduct
134
+
135
+ 1. Fork it ( https://github.com/Kaicoh/rms_api_ruby/fork )
136
+ 2. Create your feature branch (git checkout -b my-new-feature)
137
+ 3. Commit your changes (git commit -am 'Add some feature')
138
+ 4. Push to the branch (git push origin my-new-feature)
139
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rms_api_ruby"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,15 @@
1
+ require 'active_support'
2
+ require 'active_support/core_ext'
3
+ require 'waterfall'
4
+ require "rms_api_ruby/version"
5
+ require 'rms_api_ruby/config'
6
+
7
+ module RmsApiRuby
8
+ Error = Class.new(StandardError)
9
+ ServerError = Class.new(Error)
10
+ AuthenticationError = Class.new(Error)
11
+
12
+ autoload :Authentication, 'rms_api_ruby/authentication'
13
+ autoload :Chain, 'rms_api_ruby/chain'
14
+ autoload :Orders, 'rms_api_ruby/orders'
15
+ end
@@ -0,0 +1,28 @@
1
+ require 'singleton'
2
+ require 'base64'
3
+
4
+ module RmsApiRuby
5
+ class Authentication
6
+ include Singleton
7
+
8
+ attr_reader :key
9
+
10
+ def initialize
11
+ @key = "ESA #{Base64.strict_encode64(service_secret + ':' + license_key)}"
12
+ end
13
+
14
+ def self.key
15
+ instance.key
16
+ end
17
+
18
+ private
19
+
20
+ def service_secret
21
+ RmsApiRuby.configuration.service_secret
22
+ end
23
+
24
+ def license_key
25
+ RmsApiRuby.configuration.license_key
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,8 @@
1
+ module RmsApiRuby
2
+ class Chain
3
+ include Waterfall
4
+
5
+ autoload :SoapClient, 'rms_api_ruby/chain/soap_client'
6
+ autoload :Logger, 'rms_api_ruby/chain/logger'
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ module RmsApiRuby
2
+ class Chain
3
+ class Logger < RmsApiRuby::Chain
4
+ def initialize(type, message)
5
+ @type = type
6
+ @message = message
7
+ @logger = RmsApiRuby.configuration.logger
8
+ @logger.level = RmsApiRuby.configuration.log_level
9
+ end
10
+
11
+ def call
12
+ chain { @logger.send(@type, @message) }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,38 @@
1
+ require 'savon'
2
+ require 'hashie/mash'
3
+
4
+ module RmsApiRuby
5
+ class Chain
6
+ class SoapClient < RmsApiRuby::Chain
7
+ SUCCESS = 200
8
+
9
+ def initialize(wsdl, operation, message)
10
+ @client = Savon.client(wsdl: wsdl)
11
+ @operation = operation
12
+ @message = message
13
+ end
14
+
15
+ def call
16
+ chain { @response = @client.call(@operation, message: @message) }
17
+ when_falsy { status_code == SUCCESS }.
18
+ dam { handle_http_error }
19
+ chain(:response) { parse_to_mash }
20
+ end
21
+
22
+ private
23
+
24
+ def handle_http_error
25
+ message = "HTTP Request failed. Response code: #{status_code}"
26
+ RmsApiRuby::ServerError.new message
27
+ end
28
+
29
+ def status_code
30
+ @response.try(:http).try(:code)
31
+ end
32
+
33
+ def parse_to_mash
34
+ Hashie::Mash.new(@response.body).send("#{@operation}_response").return
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,93 @@
1
+ require 'logger'
2
+
3
+ module RmsApiRuby
4
+ class << self
5
+ # Returns the current configuration
6
+ #
7
+ # Example
8
+ #
9
+ # RmsApiRuby.configuration.service_secret = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
10
+ # RmsApiRuby.configuration.license_key = 'abcdefghijklmnopqrstuvwxyz'
11
+ def configuration
12
+ @configuration ||= Configuration.new
13
+ end
14
+
15
+ # Yields the Configuration
16
+ #
17
+ # Example
18
+ #
19
+ # RmsApiRuby.configure do |config|
20
+ # config.service_secret = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
21
+ # config.license_key = 'abcdefghijklmnopqrstuvwxyz'
22
+ # end
23
+ def configure
24
+ yield configuration
25
+ end
26
+ end
27
+
28
+ class Configuration
29
+ class Option
30
+ attr_reader :configuration, :name, :options
31
+
32
+ def self.define(*args)
33
+ new(*args).define
34
+ end
35
+
36
+ def initialize(configuration, name, options = {})
37
+ @configuration = configuration
38
+ @name = name
39
+ @options = options
40
+ @default = options.fetch(:default, nil)
41
+ end
42
+
43
+ def define
44
+ write_attribute
45
+ define_method if default_provided?
46
+ self
47
+ end
48
+
49
+ private
50
+
51
+ attr_reader :default
52
+ alias default_provided? default
53
+
54
+ def write_attribute
55
+ configuration.send :attr_accessor, name
56
+ end
57
+
58
+ def define_method
59
+ our_default = default
60
+ our_name = name
61
+ configuration.send :define_method, our_name do
62
+ instance_variable_get(:"@#{our_name}") ||
63
+ instance_variable_set(
64
+ :"@#{our_name}",
65
+ our_default.respond_to?(:call) ? our_default.call : our_default
66
+ )
67
+ end
68
+ end
69
+ end
70
+
71
+ class << self
72
+ attr_accessor :options
73
+
74
+ def option(*args)
75
+ option = Option.define(self, *args)
76
+ (self.options ||= []) << option.name
77
+ end
78
+ end
79
+
80
+ option :service_secret, default: -> { ENV['RMS_API_SERVICE_SECRET'] }
81
+ option :license_key, default: -> { ENV['RMS_API_LICENSE_KEY'] }
82
+ option :shop_url, default: -> { ENV['RMS_API_SHOP_URL'] }
83
+ option :version, default: '1.0'
84
+ option :user_name, default: 'rms_api_ruby'
85
+
86
+ option :logger, default: ::Logger.new(STDOUT)
87
+ option :log_level, default: ::Logger::DEBUG
88
+
89
+ def options
90
+ self.class.options
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,110 @@
1
+ require 'rms_api_ruby/authentication'
2
+ require 'rms_api_ruby/chain'
3
+ require 'rms_api_ruby/config'
4
+
5
+ module RmsApiRuby
6
+ class Orders
7
+ class << self
8
+ API_METHODS = %i[
9
+ get_order
10
+ update_order
11
+ cancel_order
12
+ change_status
13
+ decision_point
14
+ r_bank_account_transfer
15
+ change_r_bank_to_unprocessing
16
+ do_enclosure
17
+ do_un_enclosure
18
+ change_enclosure_parent
19
+ get_enclosure_list
20
+ get_request_id
21
+ get_result
22
+ ].freeze
23
+
24
+ def method_missing(method, *args)
25
+ API_METHODS.include?(method) ? call_api(method, args.first) : super
26
+ end
27
+
28
+ def respond_to_missing?(method, include_private = false)
29
+ API_METHODS.include?(method) || super
30
+ end
31
+
32
+ def call_api(api_method, args)
33
+ Flow.new.
34
+ chain(response: :response) { Client.new(api_method, args) }.
35
+ on_dam { |error| handle_error(error) }.
36
+ outflow.
37
+ try(:response)
38
+ end
39
+
40
+ def handle_error(error)
41
+ raise error
42
+ rescue ServerError, AuthenticationError => e
43
+ RmsApiRuby.logger.error(e.message)
44
+ end
45
+ end
46
+
47
+ class Client
48
+ include Waterfall
49
+
50
+ AUTH_ERRORCODE = /^E02-00/
51
+
52
+ def initialize(operation, args)
53
+ @operation = operation
54
+ @args = args
55
+ end
56
+
57
+ def call # rubocop:disable Metrics/AbcSize
58
+ chain { RmsApiRuby::Chain::Logger.new(:info, start_message) }
59
+ chain(response: :response) do
60
+ RmsApiRuby::Chain::SoapClient.new(wsdl, @operation, message)
61
+ end
62
+ when_truthy { |outflow| outflow.response.error_code =~ AUTH_ERRORCODE }.
63
+ dam { |outflow| auth_error(outflow.response) }
64
+ chain { RmsApiRuby::Chain::Logger.new(:info, complete_message) }
65
+ end
66
+
67
+ private
68
+
69
+ def message
70
+ auth_params.merge business_params
71
+ end
72
+
73
+ def auth_params
74
+ {
75
+ arg0: {
76
+ auth_key: RmsApiRuby::Authentication.key,
77
+ shop_url: RmsApiRuby.configuration.shop_url,
78
+ user_name: RmsApiRuby.configuration.user_name
79
+ }
80
+ }
81
+ end
82
+
83
+ def business_params
84
+ { arg1: @args }
85
+ end
86
+
87
+ def wsdl
88
+ "https://api.rms.rakuten.co.jp/es/#{version}/order/ws?WSDL"
89
+ end
90
+
91
+ def version
92
+ RmsApiRuby.configuration.version
93
+ end
94
+
95
+ def auth_error(response)
96
+ refference = "status: #{response.error_code}, message: #{response.message}"
97
+ message = "RMS Api authentication failed. #{refference}"
98
+ RmsApiRuby::AuthenticationError.new message
99
+ end
100
+
101
+ def start_message
102
+ "RMS OrderAPI '#{@operation.to_s.camelize}' started. args: #{@args.inspect}"
103
+ end
104
+
105
+ def complete_message
106
+ "RMS OrderAPI '#{@operation.to_s.camelize}' completed."
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,3 @@
1
+ module RmsApiRuby
2
+ VERSION = "0.1.0".freeze
3
+ end
@@ -0,0 +1,44 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "rms_api_ruby/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rms_api_ruby"
8
+ spec.version = RmsApiRuby::VERSION
9
+ spec.authors = ["Kaicoh"]
10
+ spec.email = ["sumireminami@gmail.com"]
11
+
12
+ spec.summary = %q{A Ruby client for RMS(Rakuten Marchant Service) WEB API}
13
+ spec.description = %q{A Ruby client for RMS(Rakuten Marchant Service) WEB API}
14
+ spec.homepage = "https://github.com/Kaicoh"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ # Specify which files should be added to the gem when it is released.
27
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ spec.add_dependency 'activesupport'
36
+ spec.add_dependency 'hashie'
37
+ spec.add_dependency 'savon', '~> 2.12.0'
38
+ spec.add_dependency 'waterfall', '~> 1.2.0'
39
+
40
+ spec.add_development_dependency "bundler", "~> 1.16"
41
+ spec.add_development_dependency "rake", "~> 10.0"
42
+ spec.add_development_dependency "rspec", "~> 3.0"
43
+ spec.add_development_dependency 'rubocop', '~> 0.57.1'
44
+ end
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rms_api_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kaicoh
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-06-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
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: savon
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.12.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.12.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: waterfall
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.2.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.16'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.16'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.57.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.57.1
125
+ description: A Ruby client for RMS(Rakuten Marchant Service) WEB API
126
+ email:
127
+ - sumireminami@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - ".rubocop.yml"
135
+ - ".travis.yml"
136
+ - CODE_OF_CONDUCT.md
137
+ - Gemfile
138
+ - Gemfile.lock
139
+ - LICENSE.txt
140
+ - README.md
141
+ - Rakefile
142
+ - bin/console
143
+ - bin/setup
144
+ - lib/rms_api_ruby.rb
145
+ - lib/rms_api_ruby/authentication.rb
146
+ - lib/rms_api_ruby/chain.rb
147
+ - lib/rms_api_ruby/chain/logger.rb
148
+ - lib/rms_api_ruby/chain/soap_client.rb
149
+ - lib/rms_api_ruby/config.rb
150
+ - lib/rms_api_ruby/orders.rb
151
+ - lib/rms_api_ruby/version.rb
152
+ - rms_api_ruby.gemspec
153
+ homepage: https://github.com/Kaicoh
154
+ licenses:
155
+ - MIT
156
+ metadata: {}
157
+ post_install_message:
158
+ rdoc_options: []
159
+ require_paths:
160
+ - lib
161
+ required_ruby_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ requirements: []
172
+ rubyforge_project:
173
+ rubygems_version: 2.7.7
174
+ signing_key:
175
+ specification_version: 4
176
+ summary: A Ruby client for RMS(Rakuten Marchant Service) WEB API
177
+ test_files: []