ezapi_client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: afcd05e247194fdcf5b992a0ea5828cb2eb81b5d
4
+ data.tar.gz: 0e858ff16284a01f52084ed84305142d84cacdc1
5
+ SHA512:
6
+ metadata.gz: 54f6daf693cfe443cd822c3b822d4f119bb3d5d83dd8ee51482f6611b30bbeca51e1fc03474af9b578969d04a9e44dde611b91bbedac617020378a53265c11b3
7
+ data.tar.gz: 53407f6bff84850053730464d7e7b2d1d7da3c82e670a74b57f00d6ed121550ea19c8eff7d8a39141dd52f16ae61f36c801479e9eacbde4230533e3ad154cbeb
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /spec/fixtures/*.eks
11
+ /spec/fixtures/*.prv
12
+ /spec/config.yml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.12.5
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semver.org/).
4
+
5
+ ## [0.1.0] - 2016-08-22
6
+ ### Added
7
+ - Initial working version
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at ramon.tayag@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ezapi_client.gemspec
4
+ gemspec
5
+ gem "pry"
6
+ gem "pry-byebug"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Ramon Tayag
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,36 @@
1
+ # EZAPIClient
2
+
3
+ Ruby wrapper for EasyPadala's API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ezapi_client'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ezapi_client
20
+
21
+ ## Usage
22
+
23
+ See `spec/functional` for examples.
24
+
25
+ ## Development
26
+
27
+ 1. Copy `spec/config.yml.sample` to `spec/config.yml` and fill up with your own details.
28
+ 2. `rspec spec`
29
+
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are welcome on GitHub at https://github.com/imacchiato/ezapi_client-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.
33
+
34
+ ## License
35
+
36
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
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 "ezapi_client"
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
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,40 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ezapi_client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ezapi_client"
8
+ spec.version = EZAPIClient::VERSION
9
+ spec.authors = ["Ramon Tayag"]
10
+ spec.email = ["ramon.tayag@gmail.com"]
11
+
12
+ spec.summary = %q{Ruby wrapper for EZAPI}
13
+ spec.homepage = "https://github.com/imacchiato/ezapi_client-ruby"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency "activesupport", ">= 3.0"
30
+ spec.add_dependency "virtus", "~> 1.0"
31
+ spec.add_dependency "dry-validation"
32
+ spec.add_dependency "httparty"
33
+
34
+ spec.add_development_dependency "bundler", "~> 1.12"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "rspec", "~> 3.0"
37
+ spec.add_development_dependency "virtus-matchers"
38
+ spec.add_development_dependency "vcr"
39
+ spec.add_development_dependency "webmock"
40
+ end
@@ -0,0 +1,40 @@
1
+ require "active_support/concern"
2
+ require "active_support/core_ext/hash/indifferent_access"
3
+ require "active_support/core_ext/hash/slice"
4
+ require "active_support/core_ext/object"
5
+ require "active_support/json/encoding"
6
+ require "dry-validation"
7
+ require "httparty"
8
+ require "open3"
9
+ require "virtus"
10
+ require "ezapi_client/version"
11
+ require "ezapi_client/client"
12
+ require "ezapi_client/indifferent_hash"
13
+ require "ezapi_client/concerns/password_tokenizable"
14
+ require "ezapi_client/services/exec_command"
15
+ require "ezapi_client/services/gen_password_token"
16
+ require "ezapi_client/services/gen_data"
17
+ require "ezapi_client/requests/base_request"
18
+ require "ezapi_client/requests/create_transaction_request"
19
+ require "ezapi_client/requests/check_transaction_request"
20
+ require "ezapi_client/responses/base_response"
21
+ require "ezapi_client/responses/create_transaction_response"
22
+ require "ezapi_client/responses/check_transaction_response"
23
+ require "ezapi_client/schemas/base_schema"
24
+ require "ezapi_client/schemas/client_schema"
25
+ require "ezapi_client/schemas/create_transaction_request_schema"
26
+ require "ezapi_client/schemas/check_transaction_request_schema"
27
+
28
+ module EZAPIClient
29
+
30
+ JAR_PATH = File.join(File.dirname(__FILE__), "ezapi_client/bin/ezapi.jar")
31
+
32
+ def self.new(opts)
33
+ client = Client.new(opts)
34
+ error_messages = ClientSchema.(client.attributes).
35
+ messages(full: true).values
36
+ raise ArgumentError, error_messages if error_messages.any?
37
+ client
38
+ end
39
+
40
+ end
Binary file
@@ -0,0 +1,36 @@
1
+ module EZAPIClient
2
+ class Client
3
+
4
+ include Virtus.model
5
+ attribute :host, String
6
+ attribute :username, String
7
+ attribute :password, String
8
+ attribute :eks_path, String
9
+ attribute :prv_path, String
10
+
11
+ def create_transaction(args)
12
+ opts = default_opts.merge(args)
13
+ request = CreateTransactionRequest.new(opts)
14
+ error_messages = CreateTransactionRequestSchema.
15
+ (request.attributes).messages(full: true).values
16
+ fail ArgumentError, error_messages if error_messages.any?
17
+ CreateTransactionResponse.new(raw_response: request.())
18
+ end
19
+
20
+ def check_transaction(args)
21
+ opts = default_opts.merge(args)
22
+ request = CheckTransactionRequest.new(opts)
23
+ error_messages = CheckTransactionRequestSchema.
24
+ (request.attributes).messages(full: true).values
25
+ fail ArgumentError, error_messages if error_messages.any?
26
+ CheckTransactionResponse.new(raw_response: request.())
27
+ end
28
+
29
+ private
30
+
31
+ def default_opts
32
+ attributes
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,26 @@
1
+ module EZAPIClient
2
+ module PasswordTokenizable
3
+
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ attribute(:password_token, String, {
8
+ lazy: true,
9
+ default: :default_password_token,
10
+ })
11
+ end
12
+
13
+ private
14
+
15
+ def default_password_token
16
+ GenPasswordToken.(
17
+ prv_path: prv_path,
18
+ eks_path: eks_path,
19
+ username: username,
20
+ password: password,
21
+ reference_no: reference_no,
22
+ )
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ module EZAPIClient
2
+ class IndifferentHash < Virtus::Attribute
3
+ def coerce(value)
4
+ value.is_a?(::Hash) ? value.with_indifferent_access : value
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,41 @@
1
+ module EZAPIClient
2
+ class BaseRequest
3
+
4
+ include Virtus.model
5
+ attribute :username, String
6
+ attribute :password, String
7
+ attribute :eks_path, String
8
+ attribute :prv_path, String
9
+ attribute :host, String
10
+ attribute :path, String, lazy: true, default: :default_path
11
+ attribute :endpoint, String, lazy: true, default: :default_endpoint
12
+
13
+ def call
14
+ HTTParty.post(endpoint, {
15
+ headers: { 'Content-Type' => "application/json" },
16
+ body: body.to_json,
17
+ })
18
+ end
19
+
20
+ private
21
+
22
+ def default_endpoint
23
+ full_path = if path.nil?
24
+ nil
25
+ elsif path[0].eql?("/")
26
+ path
27
+ else
28
+ "/#{path}"
29
+ end
30
+
31
+ uri = URI.parse(host)
32
+ uri.path = full_path
33
+ uri.to_s
34
+ end
35
+
36
+ def default_path
37
+ fail "Override me"
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,20 @@
1
+ module EZAPIClient
2
+ class CheckTransactionRequest < BaseRequest
3
+
4
+ include PasswordTokenizable
5
+ DEFAULT_PATH = "/sfa/transactions/check_transaction"
6
+
7
+ attribute :reference_no, String
8
+
9
+ private
10
+
11
+ def body
12
+ attributes.slice(:username, :reference_no).merge(password: password_token)
13
+ end
14
+
15
+ def default_path
16
+ DEFAULT_PATH
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,109 @@
1
+ module EZAPIClient
2
+ class CreateTransactionRequest < BaseRequest
3
+
4
+ include PasswordTokenizable
5
+ DEFAULT_PATH = "/sfa/transactions/new_transaction"
6
+
7
+ TRANS_TYPES = {
8
+ "OAB" => "Opening account for Beneficiary",
9
+ "OAR" => "Opening account for Remitter",
10
+ "CBA" => "Credit to a bank account",
11
+ "CCC" => "Credit or reload to a Credit/Debit/Cash/Prepaid Card",
12
+ "DCD" => "Door-to-door Cash Delivery",
13
+ "DCC" => "Door-to-door Cash Card Delivery",
14
+ "DJP" => "Door-to-door Jollibee Padala",
15
+ "DMP" => "Door-to-door Max's Padala",
16
+ "DSC" => "Door-to-door SM Gift Card Delivery",
17
+ "DRD" => "Door-to-door Rush Delivery",
18
+ "PCA" => "Pickup Cash @ Anywhere",
19
+ "PML" => "Pickup Cash @ MLhullier Kwarta Padala",
20
+ "PCL" => "Pickup Cash @ Cebuana Lhullier",
21
+ }
22
+
23
+ TRANS_TYPE_CATEGORIES = {
24
+ door_to_door: %w(DCD DCC DJP DMP DSC DRD),
25
+ }
26
+
27
+ attribute :reference_no, String
28
+ attribute :trans_date, Date
29
+ attribute :sender_lastname, String
30
+ attribute :sender_firstname, String
31
+ attribute :sender_middle_name, String
32
+ attribute :sender_address1, String
33
+ attribute :sender_address2, String
34
+ attribute :sender_phone, String
35
+ attribute :recipient_lastname, String
36
+ attribute :recipient_firstname, String
37
+ attribute :recipient_middle_name, String
38
+ attribute :recipient_address1, String
39
+ attribute :recipient_address2, String
40
+ attribute :recipient_phone, String
41
+ attribute :recipient_gender, String
42
+ attribute :recipient_birthday, Date
43
+ attribute :trans_type, String
44
+ attribute :bank_code, String
45
+ attribute :branch_name, String, lazy: true, default: :default_branch_name
46
+ attribute :account_no, String
47
+ attribute :landed_currency, String
48
+ attribute :landed_amount, Float
49
+ attribute :message1, String
50
+ attribute :message2, String
51
+ attribute :data, String, lazy: true, default: :default_data
52
+
53
+ private
54
+
55
+ def body
56
+ attributes.slice(:username, :reference_no, :data).
57
+ merge(password: password_token)
58
+ end
59
+
60
+ def default_branch_name
61
+ return if trans_type != "CBA"
62
+ return "MAKATI" if bank_code != "BDO"
63
+ "BDO"
64
+ end
65
+
66
+ def default_path
67
+ DEFAULT_PATH
68
+ end
69
+
70
+ def default_data
71
+ message = %i[
72
+ reference_no
73
+ trans_date
74
+ sender_lastname
75
+ sender_firstname
76
+ sender_middle_name
77
+ sender_address1
78
+ sender_address2
79
+ sender_phone
80
+ recipient_lastname
81
+ recipient_firstname
82
+ recipient_middle_name
83
+ recipient_address1
84
+ recipient_address2
85
+ recipient_phone
86
+ recipient_gender
87
+ recipient_birthday
88
+ trans_type
89
+ bank_code
90
+ branch_name
91
+ account_no
92
+ landed_currency
93
+ landed_amount
94
+ message1
95
+ message2
96
+ ].each_with_object({}) { |attr, hash| hash[attr] = send(attr) }
97
+
98
+ GenData.(
99
+ username: username,
100
+ password: password,
101
+ eks_path: eks_path,
102
+ prv_path: prv_path,
103
+ reference_no: reference_no,
104
+ message: message,
105
+ )
106
+ end
107
+
108
+ end
109
+ end
@@ -0,0 +1,33 @@
1
+ module EZAPIClient
2
+ class BaseResponse
3
+
4
+ include Virtus.model
5
+ attribute :raw_response, Object
6
+ attribute(:response_body, IndifferentHash, {
7
+ lazy: true,
8
+ default: :default_response_body,
9
+ })
10
+ attribute :success, Boolean, lazy: true, default: :default_success
11
+ attribute :code, String, lazy: true, default: :default_code
12
+ attribute :message, String, lazy: true, default: :default_message
13
+
14
+ private
15
+
16
+ def default_success
17
+ response_body[:success]
18
+ end
19
+
20
+ def default_response_body
21
+ JSON.parse(raw_response.body)
22
+ end
23
+
24
+ def default_code
25
+ response_body[:code]
26
+ end
27
+
28
+ def default_message
29
+ response_body[:message]
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ module EZAPIClient
2
+ class CheckTransactionResponse < BaseResponse
3
+
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module EZAPIClient
2
+ class CreateTransactionResponse < BaseResponse
3
+
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ module EZAPIClient
2
+ class BaseSchema < Dry::Validation::Schema
3
+
4
+ configure do
5
+ config.messages_file = File.join(File.dirname(__FILE__), "errors.yml")
6
+
7
+ def exists?(value)
8
+ File.exists?(value)
9
+ end
10
+ end
11
+
12
+ define! do
13
+ required(:host).filled
14
+ required(:username).filled
15
+ required(:password).filled
16
+ required(:eks_path).filled(:exists?)
17
+ required(:prv_path).filled(:exists?)
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ module EZAPIClient
2
+ CheckTransactionRequestSchema = Dry::Validation.Schema(BaseSchema) do
3
+
4
+ required(:reference_no).filled(:str?, max_size?: 20)
5
+
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module EZAPIClient
2
+ ClientSchema = Dry::Validation.Schema(BaseSchema) do
3
+
4
+ end
5
+ end
@@ -0,0 +1,51 @@
1
+ module EZAPIClient
2
+ CreateTransactionRequestSchema = Dry::Validation.Schema(BaseSchema) do
3
+
4
+ required(:reference_no).filled(:str?, max_size?: 20)
5
+ required(:trans_date).filled(:date?)
6
+ required(:sender_lastname).filled(:str?, max_size?: 40)
7
+ required(:sender_firstname).filled(:str?, max_size?: 40)
8
+ required(:sender_middle_name).maybe(:str?, max_size?: 1)
9
+ required(:sender_address1).filled(:str?, max_size?: 75)
10
+ required(:sender_address2).maybe(:str?, max_size?: 75)
11
+ required(:sender_phone).maybe(:str?, max_size?: 30)
12
+ required(:recipient_lastname).filled(:str?, max_size?: 40)
13
+ required(:recipient_firstname).filled(:str?, max_size?: 40)
14
+ required(:recipient_middle_name).maybe(:str?, max_size?: 1)
15
+ required(:recipient_address1).filled(:str?, max_size?: 75)
16
+ required(:recipient_address2).maybe(:str?, max_size?: 75)
17
+ required(:recipient_phone).maybe(:str?, max_size?: 30)
18
+ required(:recipient_gender).maybe(:str?, max_size?: 1)
19
+ required(:recipient_birthday).maybe(:date?)
20
+ required(:trans_type).filled(:str?, {
21
+ max_size?: 3,
22
+ included_in?: CreateTransactionRequest::TRANS_TYPES.keys,
23
+ })
24
+ required(:bank_code).filled(:str?, max_size?: 5)
25
+ required(:branch_name).filled(:str?, max_size?: 40)
26
+ required(:account_no).filled(:str?, max_size?: 20)
27
+ required(:landed_currency).filled(:str?, {
28
+ max_size?: 3,
29
+ included_in?: %w(USD PHP),
30
+ })
31
+ required(:landed_amount).filled(:float?)
32
+ required(:message1).maybe(:str?, max_size?: 50)
33
+ required(:message2).maybe(:str?, max_size?: 50)
34
+
35
+ rule(
36
+ recipient_birthday_presence: %i[trans_type recipient_birthday]
37
+ ) do |trans_type, recipient_birthday|
38
+ trans_types = CreateTransactionRequest::\
39
+ TRANS_TYPE_CATEGORIES[:door_to_door]
40
+ trans_type.included_in?(trans_types).then(recipient_birthday.filled?)
41
+ end
42
+
43
+ rule(
44
+ recipient_phone_presence: %i[trans_type recipient_phone]
45
+ ) do |trans_type, recipient_phone|
46
+ trans_types = %w(PCA CBA DCD DCC DJP DMP)
47
+ trans_type.included_in?(trans_types).then(recipient_phone.filled?)
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,4 @@
1
+ ---
2
+ en:
3
+ errors:
4
+ exists?: "must exist"
@@ -0,0 +1,20 @@
1
+ module EZAPIClient
2
+ class ExecCommand
3
+
4
+ include Virtus.model
5
+ attribute :command, String
6
+
7
+ def self.call(command)
8
+ self.new(command: command).()
9
+ end
10
+
11
+ def call
12
+ stdout_str, stderr_str, status = Open3.capture3(command)
13
+ unless status.success?
14
+ fail(ArgumentError, "Error executing command: #{stderr_str}")
15
+ end
16
+ stdout_str.chomp
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,45 @@
1
+ module EZAPIClient
2
+ class GenData
3
+
4
+ include Virtus.model
5
+ attribute :username, String
6
+ attribute :password, String
7
+ attribute :prv_path, String
8
+ attribute :eks_path, String
9
+ attribute :reference_no, String
10
+ attribute :message, Hash
11
+ attribute :json, String, lazy: true, default: :default_json
12
+ attribute :command, String, lazy: true, default: :default_command
13
+
14
+ def self.call(attributes)
15
+ self.new(attributes).()
16
+ end
17
+
18
+ def call
19
+ ExecCommand.(command)
20
+ end
21
+
22
+ private
23
+
24
+ def default_command
25
+ [
26
+ "java -cp",
27
+ JAR_PATH,
28
+ "ezpadala.EZdata",
29
+ prv_path,
30
+ eks_path,
31
+ username,
32
+ password,
33
+ reference_no,
34
+ "'#{json}'",
35
+ ].join(" ")
36
+ end
37
+
38
+ def default_json
39
+ message.each_with_object({}) do |(key, value), hash|
40
+ hash[key.to_s.camelcase(:lower)] = value
41
+ end.to_json
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,36 @@
1
+ module EZAPIClient
2
+ class GenPasswordToken
3
+
4
+ include Virtus.model
5
+ attribute :eks_path, String
6
+ attribute :prv_path, String
7
+ attribute :username, String
8
+ attribute :password, String
9
+ attribute :reference_no, String
10
+ attribute :command, String, lazy: true, default: :default_command
11
+
12
+ def self.call(args)
13
+ self.new(args).call
14
+ end
15
+
16
+ def call
17
+ ExecCommand.(command)
18
+ end
19
+
20
+ private
21
+
22
+ def default_command
23
+ [
24
+ "java -cp",
25
+ JAR_PATH,
26
+ "ezpadala.EZtoken",
27
+ prv_path,
28
+ eks_path,
29
+ username,
30
+ password,
31
+ reference_no,
32
+ ].join(" ")
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module EZAPIClient
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,217 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ezapi_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ramon Tayag
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-08-22 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: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: virtus
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: dry-validation
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'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
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: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.12'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.12'
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: virtus-matchers
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: vcr
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: webmock
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description:
154
+ email:
155
+ - ramon.tayag@gmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".rspec"
162
+ - ".travis.yml"
163
+ - CHANGELOG.md
164
+ - CODE_OF_CONDUCT.md
165
+ - Gemfile
166
+ - LICENSE.txt
167
+ - README.md
168
+ - Rakefile
169
+ - bin/console
170
+ - bin/setup
171
+ - ezapi_client.gemspec
172
+ - lib/ezapi_client.rb
173
+ - lib/ezapi_client/bin/ezapi.jar
174
+ - lib/ezapi_client/client.rb
175
+ - lib/ezapi_client/concerns/password_tokenizable.rb
176
+ - lib/ezapi_client/indifferent_hash.rb
177
+ - lib/ezapi_client/requests/base_request.rb
178
+ - lib/ezapi_client/requests/check_transaction_request.rb
179
+ - lib/ezapi_client/requests/create_transaction_request.rb
180
+ - lib/ezapi_client/responses/base_response.rb
181
+ - lib/ezapi_client/responses/check_transaction_response.rb
182
+ - lib/ezapi_client/responses/create_transaction_response.rb
183
+ - lib/ezapi_client/schemas/base_schema.rb
184
+ - lib/ezapi_client/schemas/check_transaction_request_schema.rb
185
+ - lib/ezapi_client/schemas/client_schema.rb
186
+ - lib/ezapi_client/schemas/create_transaction_request_schema.rb
187
+ - lib/ezapi_client/schemas/errors.yml
188
+ - lib/ezapi_client/services/exec_command.rb
189
+ - lib/ezapi_client/services/gen_data.rb
190
+ - lib/ezapi_client/services/gen_password_token.rb
191
+ - lib/ezapi_client/version.rb
192
+ homepage: https://github.com/imacchiato/ezapi_client-ruby
193
+ licenses:
194
+ - MIT
195
+ metadata:
196
+ allowed_push_host: https://rubygems.org
197
+ post_install_message:
198
+ rdoc_options: []
199
+ require_paths:
200
+ - lib
201
+ required_ruby_version: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ required_rubygems_version: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: '0'
211
+ requirements: []
212
+ rubyforge_project:
213
+ rubygems_version: 2.6.4
214
+ signing_key:
215
+ specification_version: 4
216
+ summary: Ruby wrapper for EZAPI
217
+ test_files: []