pokepay_partner_ruby_sdk 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +30 -0
- data/LICENSE.txt +7 -0
- data/README.md +54 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config.ini.sample +5 -0
- data/docs/index.md +29 -0
- data/examples/examples.rb +16 -0
- data/lib/pokepay_partner_ruby_sdk/client.rb +99 -0
- data/lib/pokepay_partner_ruby_sdk/crypto.rb +32 -0
- data/lib/pokepay_partner_ruby_sdk/request/create_transaction.rb +17 -0
- data/lib/pokepay_partner_ruby_sdk/request/list_transactions.rb +12 -0
- data/lib/pokepay_partner_ruby_sdk/request/request.rb +14 -0
- data/lib/pokepay_partner_ruby_sdk/request/send_echo.rb +12 -0
- data/lib/pokepay_partner_ruby_sdk/response/account.rb +16 -0
- data/lib/pokepay_partner_ruby_sdk/response/echo.rb +10 -0
- data/lib/pokepay_partner_ruby_sdk/response/organization.rb +10 -0
- data/lib/pokepay_partner_ruby_sdk/response/pagination.rb +16 -0
- data/lib/pokepay_partner_ruby_sdk/response/private_money.rb +28 -0
- data/lib/pokepay_partner_ruby_sdk/response/response.rb +20 -0
- data/lib/pokepay_partner_ruby_sdk/response/transaction.rb +33 -0
- data/lib/pokepay_partner_ruby_sdk/response/transactions.rb +15 -0
- data/lib/pokepay_partner_ruby_sdk/response/user.rb +12 -0
- data/lib/pokepay_partner_ruby_sdk/version.rb +3 -0
- data/lib/pokepay_partner_ruby_sdk.rb +21 -0
- data/pokepay_partner_ruby_sdk.gemspec +35 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 015dc3b92d9ad253a74ec83550047f20afdf6d99e3820dc313ee15a8e8e1bed5
|
4
|
+
data.tar.gz: 189c9ff489aa5093c5014e0d4fdb85693b3755b72b98274a06814a38efd4a037
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f0a69b091a89ff1f71588ccb778c0433a80794b7565460106ce549204f540ccf70eeb0b99ddd1e8b51d4c05c5f8cd7db123a1417908a63ec07d2c667c1f5fd6
|
7
|
+
data.tar.gz: c35badfaf92b55ff5d4255e213d44dceb2ae2a3f4d5782b33f76759ff8ad0434267698f5a2b433d4f0f42c22898004e2d95e25c008770e0f964210b7cc64b5f1
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pokepay_partner_ruby_sdk (0.1.0)
|
5
|
+
inifile (~> 3.0.0)
|
6
|
+
json (~> 2.1.0)
|
7
|
+
openssl (~> 2.1.2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
inifile (3.0.0)
|
13
|
+
ipaddr (1.2.2)
|
14
|
+
json (2.1.0)
|
15
|
+
minitest (5.11.3)
|
16
|
+
openssl (2.1.2)
|
17
|
+
ipaddr
|
18
|
+
rake (10.5.0)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
bundler (~> 2.0)
|
25
|
+
minitest (~> 5.0)
|
26
|
+
pokepay_partner_ruby_sdk!
|
27
|
+
rake (~> 10.0)
|
28
|
+
|
29
|
+
BUNDLED WITH
|
30
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright 2019 Pocket Change, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# PokepayPartnerRubySdk
|
2
|
+
|
3
|
+
Pokepay Partner API SDK for Ruby.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'pokepay_partner_ruby_sdk'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install pokepay_partner_ruby_sdk
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require "pokepay_partner_ruby_sdk"
|
25
|
+
c = Pokepay::Client.new("/path/to/config.ini")
|
26
|
+
res = c.send(Pokepay::Request::SendEcho.new('hello'))
|
27
|
+
res = c.send(Pokepay::Request::ListTransactions.new({'per_page'=>1}))
|
28
|
+
|
29
|
+
shop_id = "8b9fbece-73fa-494d-bad5-c7fd9e52f9a0"
|
30
|
+
customer_id = "78e56df5-dd71-4554-86e5-b0eb8d3781cb"
|
31
|
+
private_money_id = "4b138a4c-8944-4f98-a5c4-96d3c1c415eb"
|
32
|
+
money_amount = 100
|
33
|
+
point_amount = 200
|
34
|
+
description = "topup test"
|
35
|
+
response = c.send(Pokepay::Request::CreateTransaction.new(
|
36
|
+
shop_id, customer_id, private_money_id,
|
37
|
+
money_amount, point_amount, description))
|
38
|
+
```
|
39
|
+
|
40
|
+
## Run test
|
41
|
+
|
42
|
+
```
|
43
|
+
$ bundle exec ruby test/pokepay_partner_ruby_sdk_test.rb
|
44
|
+
```
|
45
|
+
|
46
|
+
## Development
|
47
|
+
|
48
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
49
|
+
|
50
|
+
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).
|
51
|
+
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/pokepay/pokepay_partner_ruby_sdk.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pokepay_partner_ruby_sdk"
|
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
data/config.ini.sample
ADDED
data/docs/index.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Installation
|
2
|
+
|
3
|
+
```
|
4
|
+
$ bundle exec rake install
|
5
|
+
```
|
6
|
+
|
7
|
+
# Settings
|
8
|
+
|
9
|
+
# Getting Started
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
require "pokepay_partner_ruby_sdk"
|
13
|
+
c = Pokepay::Client.new("/path/to/config.ini")
|
14
|
+
res = c.send(Pokepay::Request::SendEcho.new('hello'))
|
15
|
+
res = c.send(Pokepay::Request::ListTransactions.new({'per_page'=>1}))
|
16
|
+
res = c.send(Pokepay::Request::CreateTransaction.new(
|
17
|
+
"8b9fbece-73fa-494d-bad5-c7fd9e52f9a0",
|
18
|
+
"78e56df5-dd71-4554-86e5-b0eb8d3781cb",
|
19
|
+
"4b138a4c-8944-4f98-a5c4-96d3c1c415eb",
|
20
|
+
100,
|
21
|
+
200,
|
22
|
+
"チャージテスト"))
|
23
|
+
```
|
24
|
+
|
25
|
+
# Run test
|
26
|
+
|
27
|
+
```
|
28
|
+
$ bundle exec ruby test/pokepay_partner_ruby_sdk_test.rb
|
29
|
+
```
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require "pokepay_partner_ruby_sdk"
|
3
|
+
|
4
|
+
c = Pokepay::Client.new("~/.pokepay/config.ini")
|
5
|
+
res = c.send(Pokepay::Request::SendEcho.new('hello'))
|
6
|
+
res = c.send(Pokepay::Request::ListTransactions.new({'per_page'=>1}))
|
7
|
+
|
8
|
+
shop_id = "8b9fbece-73fa-494d-bad5-c7fd9e52f9a0"
|
9
|
+
customer_id = "78e56df5-dd71-4554-86e5-b0eb8d3781cb"
|
10
|
+
private_money_id = "4b138a4c-8944-4f98-a5c4-96d3c1c415eb"
|
11
|
+
money_amount = 100
|
12
|
+
point_amount = 200
|
13
|
+
description = "チャージテスト"
|
14
|
+
response = c.send(Pokepay::Request::CreateTransaction.new(
|
15
|
+
shop_id, customer_id, private_money_id,
|
16
|
+
money_amount, point_amount, description))
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "openssl"
|
4
|
+
require "base64"
|
5
|
+
require "uri"
|
6
|
+
require "net/https"
|
7
|
+
require "time"
|
8
|
+
require "json"
|
9
|
+
require "securerandom"
|
10
|
+
require "inifile"
|
11
|
+
require "pokepay_partner_ruby_sdk/crypto"
|
12
|
+
|
13
|
+
module Pokepay
|
14
|
+
class Client
|
15
|
+
def initialize(path_to_inifile)
|
16
|
+
path = File.expand_path(path_to_inifile)
|
17
|
+
if File.exist?(path)
|
18
|
+
ini = IniFile.load(path)
|
19
|
+
else
|
20
|
+
raise "init file does not exist."
|
21
|
+
end
|
22
|
+
@client_id = ini['global']['CLIENT_ID']
|
23
|
+
@client_secret = ini['global']['CLIENT_SECRET']
|
24
|
+
@api_base_url = URI.parse(ini['global']['API_BASE_URL'])
|
25
|
+
@ssl_key_file = ini['global']['SSL_KEY_FILE']
|
26
|
+
@ssl_cert_file = ini['global']['SSL_CERT_FILE']
|
27
|
+
@timezone = ini['global']['TIMEZONE']
|
28
|
+
@timeout = ini['global']['TIMEOUT']
|
29
|
+
@https = Net::HTTP.new(@api_base_url.host, @api_base_url.port)
|
30
|
+
@https.use_ssl = true
|
31
|
+
@https.cert = OpenSSL::X509::Certificate.new(File.read(@ssl_cert_file))
|
32
|
+
@https.key = OpenSSL::PKey::RSA.new(File.read(@ssl_key_file))
|
33
|
+
@https.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
34
|
+
@crypto = Pokepay::Crypto.new(@client_secret)
|
35
|
+
end
|
36
|
+
|
37
|
+
def is_success(res)
|
38
|
+
code = res.code.to_i
|
39
|
+
200 <= code and code < 300
|
40
|
+
end
|
41
|
+
|
42
|
+
def request(request_class, path, body_params, response_class)
|
43
|
+
encrypt_data = { 'request_data' => body_params,
|
44
|
+
'timestamp' => Time.now.iso8601(6),
|
45
|
+
'partner_call_id' => SecureRandom.uuid }
|
46
|
+
params = {"partner_client_id" => @client_id,
|
47
|
+
"data" => Base64.urlsafe_encode64(@crypto.encrypt(JSON.generate(encrypt_data)))}
|
48
|
+
req = request_class.new(path)
|
49
|
+
req.set_form_data(params)
|
50
|
+
res = @https.start { @https.request(req) }
|
51
|
+
res_map = JSON.parse(res.body)
|
52
|
+
if(res_map["response_data"]) then
|
53
|
+
res.body =
|
54
|
+
JSON.parse(@crypto.decrypt(Base64.urlsafe_decode64(res_map["response_data"]))
|
55
|
+
.force_encoding("utf-8"))
|
56
|
+
else
|
57
|
+
res.body = res_map
|
58
|
+
end
|
59
|
+
|
60
|
+
if is_success(res) and response_class
|
61
|
+
Pokepay::Response::Response.new(res, response_class.new(res.body))
|
62
|
+
else
|
63
|
+
res
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def get(path, body_params)
|
68
|
+
request(Net::HTTP::Get, path, body_params, nil)
|
69
|
+
end
|
70
|
+
|
71
|
+
def post(path, body_params)
|
72
|
+
request(Net::HTTP::Post, path, body_params, nil)
|
73
|
+
end
|
74
|
+
|
75
|
+
def delete(path, body_params)
|
76
|
+
request(Net::HTTP::Delete, path, body_params, nil)
|
77
|
+
end
|
78
|
+
|
79
|
+
def patch(path, body_params)
|
80
|
+
request(Net::HTTP::Patch, path, body_params, nil)
|
81
|
+
end
|
82
|
+
|
83
|
+
def put(path, body_params)
|
84
|
+
request(Net::HTTP::Put, path, body_params, nil)
|
85
|
+
end
|
86
|
+
|
87
|
+
def send(request)
|
88
|
+
request_class = case request.method
|
89
|
+
when "GET" then Net::HTTP::Get
|
90
|
+
when "POST" then Net::HTTP::Post
|
91
|
+
when "DELETE" then Net::HTTP::Delete
|
92
|
+
when "PATCH" then Net::HTTP::Patch
|
93
|
+
when "PUT" then Net::HTTP::Put
|
94
|
+
else raise "Wrong method"
|
95
|
+
end
|
96
|
+
request(request_class, request.path, request.body_params, request.response_class)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "openssl"
|
4
|
+
require "base64"
|
5
|
+
require "securerandom"
|
6
|
+
|
7
|
+
module Pokepay
|
8
|
+
class Crypto
|
9
|
+
def initialize(key)
|
10
|
+
@key = Base64.urlsafe_decode64(key).force_encoding("utf-8")
|
11
|
+
@cipher = OpenSSL::Cipher.new('AES-256-CBC')
|
12
|
+
end
|
13
|
+
|
14
|
+
def encrypt(plaintext)
|
15
|
+
enc = @cipher
|
16
|
+
enc.encrypt
|
17
|
+
enc.key = @key
|
18
|
+
enc.padding = 1
|
19
|
+
enc.iv = SecureRandom.random_bytes(16)
|
20
|
+
enc.update('0'*16 + plaintext) + enc.final
|
21
|
+
end
|
22
|
+
|
23
|
+
def decrypt(ciphertext)
|
24
|
+
dec = @cipher
|
25
|
+
dec.decrypt
|
26
|
+
dec.key = @key
|
27
|
+
dec.iv = ciphertext.byteslice(0,16)
|
28
|
+
decrypted_text = dec.update(ciphertext) + dec.final
|
29
|
+
decrypted_text.byteslice(16, decrypted_text.bytesize - 16)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "pokepay_partner_ruby_sdk/response/transaction"
|
2
|
+
|
3
|
+
module Pokepay::Request
|
4
|
+
class CreateTransaction < Request
|
5
|
+
def initialize(shop_id, customer_id, private_money_id, money_amount, point_amount, description)
|
6
|
+
@path = "/transactions"
|
7
|
+
@method = "POST"
|
8
|
+
@body_params = { "shop_id" => shop_id,
|
9
|
+
"customer_id" => customer_id,
|
10
|
+
"private_money_id" => private_money_id,
|
11
|
+
"money_amount" => money_amount,
|
12
|
+
"point_amount" => point_amount,
|
13
|
+
"description" => description }
|
14
|
+
@response_class = Pokepay::Response::Transaction
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "pokepay_partner_ruby_sdk/response/transactions"
|
2
|
+
|
3
|
+
module Pokepay::Request
|
4
|
+
class ListTransactions < Request
|
5
|
+
def initialize(filter_args)
|
6
|
+
@path = "/transactions"
|
7
|
+
@method = "GET"
|
8
|
+
@body_params = filter_args
|
9
|
+
@response_class = Pokepay::Response::Transactions
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Pokepay::Request
|
2
|
+
class Request
|
3
|
+
def initialize()
|
4
|
+
@path = "/"
|
5
|
+
@method = "GET"
|
6
|
+
@body_params = nil
|
7
|
+
@response_class = nil
|
8
|
+
end
|
9
|
+
attr_reader :path
|
10
|
+
attr_reader :method
|
11
|
+
attr_reader :body_params
|
12
|
+
attr_reader :response_class
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "pokepay_partner_ruby_sdk/response/echo"
|
2
|
+
|
3
|
+
module Pokepay::Request
|
4
|
+
class SendEcho < Request
|
5
|
+
def initialize(message)
|
6
|
+
@path = "/echo"
|
7
|
+
@method = "POST"
|
8
|
+
@body_params = {"message" => message}
|
9
|
+
@response_class = Pokepay::Response::Echo
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "pokepay_partner_ruby_sdk/response/private_money"
|
2
|
+
|
3
|
+
module Pokepay::Response
|
4
|
+
class Account
|
5
|
+
def initialize(row)
|
6
|
+
@id = row["id"]
|
7
|
+
@name = row["name"]
|
8
|
+
@is_suspended = row["is_suspended"]
|
9
|
+
@private_money = PrivateMoney.new(row["private_money"])
|
10
|
+
end
|
11
|
+
attr_reader :id
|
12
|
+
attr_reader :name
|
13
|
+
attr_reader :is_suspended
|
14
|
+
attr_reader :private_money
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Pokepay::Response
|
2
|
+
class Pagination
|
3
|
+
def initialize(response_map)
|
4
|
+
@current = response_map["current"]
|
5
|
+
@per_page = response_map["per_page"]
|
6
|
+
@max_page = response_map["max_page"]
|
7
|
+
@has_prev = response_map["has_prev"]
|
8
|
+
@has_next = response_map["has_next"]
|
9
|
+
end
|
10
|
+
attr_reader :current
|
11
|
+
attr_reader :per_page
|
12
|
+
attr_reader :max_page
|
13
|
+
attr_reader :has_prev
|
14
|
+
attr_reader :has_next
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "pokepay_partner_ruby_sdk/response/organization"
|
2
|
+
|
3
|
+
module Pokepay::Response
|
4
|
+
class PrivateMoney
|
5
|
+
def initialize(row)
|
6
|
+
@id = row["id"]
|
7
|
+
@name = row["name"]
|
8
|
+
@unit = row["unit"]
|
9
|
+
@is_exclusive = row["is_exclusive"]
|
10
|
+
@description = row["description"]
|
11
|
+
@organization = Organization.new(row["organization"])
|
12
|
+
@max_balance = row["max_balance"]
|
13
|
+
@transfer_limit = row["transfer_limit"]
|
14
|
+
@type = row["type"]
|
15
|
+
@expiration_type = row["expiration_type"]
|
16
|
+
end
|
17
|
+
attr_reader :id
|
18
|
+
attr_reader :name
|
19
|
+
attr_reader :unit
|
20
|
+
attr_reader :is_exclusive
|
21
|
+
attr_reader :description
|
22
|
+
attr_reader :organization
|
23
|
+
attr_reader :max_balance
|
24
|
+
attr_reader :transfer_limit
|
25
|
+
attr_reader :type
|
26
|
+
attr_reader :expiration_type
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "net/https"
|
2
|
+
|
3
|
+
module Pokepay::Response
|
4
|
+
class Response < Net::HTTPResponse
|
5
|
+
def initialize(response, object)
|
6
|
+
@body = response.body
|
7
|
+
@object = object
|
8
|
+
@code = response.code
|
9
|
+
@header = response.header
|
10
|
+
@http_version = response.http_version
|
11
|
+
@message = response.message
|
12
|
+
end
|
13
|
+
attr_reader :body
|
14
|
+
attr_reader :object
|
15
|
+
attr_reader :code
|
16
|
+
attr_reader :header
|
17
|
+
attr_reader :http_version
|
18
|
+
attr_reader :message
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "pokepay_partner_ruby_sdk/response/user"
|
2
|
+
require "pokepay_partner_ruby_sdk/response/account"
|
3
|
+
|
4
|
+
module Pokepay::Response
|
5
|
+
class Transaction
|
6
|
+
def initialize(row)
|
7
|
+
@id = row["id"]
|
8
|
+
@type = row["type"]
|
9
|
+
@is_modified = row["is_modified"]
|
10
|
+
@sender = User.new(row["sender"])
|
11
|
+
@sender_account = Account.new(row["sender_account"])
|
12
|
+
@receiver = User.new(row["receiver"])
|
13
|
+
@receiver_account = Account.new(row["receiver_account"])
|
14
|
+
@amount = row["amount"]
|
15
|
+
@money_amount = row["money_amount"]
|
16
|
+
@point_amount = row["point_amount"]
|
17
|
+
@done_at = Time.parse(row["done_at"]).localtime
|
18
|
+
@description = row["description"]
|
19
|
+
end
|
20
|
+
attr_reader :id
|
21
|
+
attr_reader :type
|
22
|
+
attr_reader :is_modified
|
23
|
+
attr_reader :sender
|
24
|
+
attr_reader :sender_account
|
25
|
+
attr_reader :receiver
|
26
|
+
attr_reader :receiver_account
|
27
|
+
attr_reader :amount
|
28
|
+
attr_reader :money_amount
|
29
|
+
attr_reader :point_amount
|
30
|
+
attr_reader :done_at
|
31
|
+
attr_reader :description
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "pokepay_partner_ruby_sdk/response/transaction"
|
2
|
+
require "pokepay_partner_ruby_sdk/response/pagination"
|
3
|
+
|
4
|
+
module Pokepay::Response
|
5
|
+
class Transactions
|
6
|
+
def initialize(res)
|
7
|
+
@rows = res["rows"].map{|row| Transaction.new(row)}
|
8
|
+
@count = res["count"]
|
9
|
+
@pagination = Pagination.new(res["pagination"])
|
10
|
+
end
|
11
|
+
attr_reader :rows
|
12
|
+
attr_reader :count
|
13
|
+
attr_reader :pagination
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "pokepay_partner_ruby_sdk/version"
|
4
|
+
require "pokepay_partner_ruby_sdk/client"
|
5
|
+
require "pokepay_partner_ruby_sdk/request/request"
|
6
|
+
require "pokepay_partner_ruby_sdk/request/send_echo"
|
7
|
+
require "pokepay_partner_ruby_sdk/request/create_transaction"
|
8
|
+
require "pokepay_partner_ruby_sdk/request/list_transactions"
|
9
|
+
require "pokepay_partner_ruby_sdk/response/response"
|
10
|
+
require "pokepay_partner_ruby_sdk/response/echo"
|
11
|
+
require "pokepay_partner_ruby_sdk/response/account"
|
12
|
+
require "pokepay_partner_ruby_sdk/response/pagination"
|
13
|
+
require "pokepay_partner_ruby_sdk/response/private_money"
|
14
|
+
require "pokepay_partner_ruby_sdk/response/transaction"
|
15
|
+
require "pokepay_partner_ruby_sdk/response/transactions"
|
16
|
+
require "pokepay_partner_ruby_sdk/response/user"
|
17
|
+
require "pokepay_partner_ruby_sdk/response/organization"
|
18
|
+
|
19
|
+
module Pokepay
|
20
|
+
class Error < StandardError; end
|
21
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "pokepay_partner_ruby_sdk/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "pokepay_partner_ruby_sdk"
|
7
|
+
spec.version = Pokepay::VERSION
|
8
|
+
spec.authors = ["Satoshi Imai"]
|
9
|
+
spec.email = ["satoshi.imai@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Pokepay Partner API SDK for Ruby}
|
12
|
+
spec.description = %q{Pokepay Partner API SDK for Ruby}
|
13
|
+
spec.homepage = "https://github.com/pokepay/partner_ruby_sdk"
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = "https://github.com/pokepay/partner_ruby_sdk"
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/pokepay/partner_ruby_sdk"
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
31
|
+
|
32
|
+
spec.add_dependency "openssl", "~> 2.1.2"
|
33
|
+
spec.add_dependency "json", "~> 2.1.0"
|
34
|
+
spec.add_dependency "inifile", "~> 3.0.0"
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pokepay_partner_ruby_sdk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Satoshi Imai
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-09-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: openssl
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.1.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.1.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.1.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.1.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: inifile
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.0.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.0.0
|
97
|
+
description: Pokepay Partner API SDK for Ruby
|
98
|
+
email:
|
99
|
+
- satoshi.imai@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- Gemfile
|
107
|
+
- Gemfile.lock
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- config.ini.sample
|
114
|
+
- docs/index.md
|
115
|
+
- examples/examples.rb
|
116
|
+
- lib/pokepay_partner_ruby_sdk.rb
|
117
|
+
- lib/pokepay_partner_ruby_sdk/client.rb
|
118
|
+
- lib/pokepay_partner_ruby_sdk/crypto.rb
|
119
|
+
- lib/pokepay_partner_ruby_sdk/request/create_transaction.rb
|
120
|
+
- lib/pokepay_partner_ruby_sdk/request/list_transactions.rb
|
121
|
+
- lib/pokepay_partner_ruby_sdk/request/request.rb
|
122
|
+
- lib/pokepay_partner_ruby_sdk/request/send_echo.rb
|
123
|
+
- lib/pokepay_partner_ruby_sdk/response/account.rb
|
124
|
+
- lib/pokepay_partner_ruby_sdk/response/echo.rb
|
125
|
+
- lib/pokepay_partner_ruby_sdk/response/organization.rb
|
126
|
+
- lib/pokepay_partner_ruby_sdk/response/pagination.rb
|
127
|
+
- lib/pokepay_partner_ruby_sdk/response/private_money.rb
|
128
|
+
- lib/pokepay_partner_ruby_sdk/response/response.rb
|
129
|
+
- lib/pokepay_partner_ruby_sdk/response/transaction.rb
|
130
|
+
- lib/pokepay_partner_ruby_sdk/response/transactions.rb
|
131
|
+
- lib/pokepay_partner_ruby_sdk/response/user.rb
|
132
|
+
- lib/pokepay_partner_ruby_sdk/version.rb
|
133
|
+
- pokepay_partner_ruby_sdk.gemspec
|
134
|
+
homepage: https://github.com/pokepay/partner_ruby_sdk
|
135
|
+
licenses: []
|
136
|
+
metadata:
|
137
|
+
homepage_uri: https://github.com/pokepay/partner_ruby_sdk
|
138
|
+
source_code_uri: https://github.com/pokepay/partner_ruby_sdk
|
139
|
+
changelog_uri: https://github.com/pokepay/partner_ruby_sdk
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
requirements: []
|
155
|
+
rubygems_version: 3.0.3
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: Pokepay Partner API SDK for Ruby
|
159
|
+
test_files: []
|