pokepay_partner_ruby_sdk 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 015dc3b92d9ad253a74ec83550047f20afdf6d99e3820dc313ee15a8e8e1bed5
4
- data.tar.gz: 189c9ff489aa5093c5014e0d4fdb85693b3755b72b98274a06814a38efd4a037
3
+ metadata.gz: b462bd0f2ea7bce3ec40b034bb138999de416b4618f956042d97cce6ab592ffa
4
+ data.tar.gz: 887c9023e4346498b6ef4cef2e0cebd125d9b28e5d19fe0ff06ad7e489eb645d
5
5
  SHA512:
6
- metadata.gz: 2f0a69b091a89ff1f71588ccb778c0433a80794b7565460106ce549204f540ccf70eeb0b99ddd1e8b51d4c05c5f8cd7db123a1417908a63ec07d2c667c1f5fd6
7
- data.tar.gz: c35badfaf92b55ff5d4255e213d44dceb2ae2a3f4d5782b33f76759ff8ad0434267698f5a2b433d4f0f42c22898004e2d95e25c008770e0f964210b7cc64b5f1
6
+ metadata.gz: e1e978f24e716234f533e02221f9e77c6f56f892fa6be91ff998be328fcf231ba47ddad601736bd6df5c6c5a3ec28b143aeabe369dcd33601ab27eb06684c536
7
+ data.tar.gz: 5a722a10444c8ac32a2ed0b61408925ffc336d1367b14c2cce51c20a5b41f9d4fbcafe2042bdd16541c3184f5d15957b7cb41b85bacf226910c11f341ab67130
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pokepay_partner_ruby_sdk (0.1.0)
4
+ pokepay_partner_ruby_sdk (0.1.1)
5
5
  inifile (~> 3.0.0)
6
6
  json (~> 2.1.0)
7
7
  openssl (~> 2.1.2)
data/config.ini.sample CHANGED
@@ -1,5 +1,5 @@
1
1
  CLIENT_ID = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
2
2
  CLIENT_SECRET = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
3
- API_BASE_URL = https://partnerapi-dev.pokepay.jp
3
+ API_BASE_URL = https://partnerapi-sandbox.pokepay.jp
4
4
  SSL_KEY_FILE = /path/to/key.pem
5
5
  SSL_CERT_FILE = /path/to/cert.pem
data/docs/index.md CHANGED
@@ -1,29 +1,213 @@
1
- # Installation
1
+ # Partner API SDK for Ruby
2
2
 
3
+ ## Installation
4
+
5
+ rubygemsからインストールすることができます。
6
+ ```
7
+ $ gem install pokepay_partner_ruby_sdk
3
8
  ```
4
- $ bundle exec rake install
9
+
10
+ ロードパスの通ったところにライブラリが配置されていれば、以下のようにロードできます。
11
+
12
+ ```ruby
13
+ require "pokepay_partner_ruby_sdk"
5
14
  ```
6
15
 
7
- # Settings
16
+ ## Getting started
8
17
 
9
- # Getting Started
18
+ 基本的な使い方は次のようになります。
19
+
20
+ - ライブラリをロード
21
+ - 設定ファイル(後述)から Pokepay::Client オブジェクトを作る
22
+ - リクエストオブジェクトを作り、Pokepay::Client オブジェクトのsendメソッドに対して渡す
23
+ - レスポンスオブジェクトを得る
10
24
 
11
25
  ```ruby
12
26
  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
- "チャージテスト"))
27
+ client = Pokepay::Client.new("/path/to/config.ini")
28
+ request = Pokepay::Request::SendEcho.new('hello')
29
+ response = client.send(request)
30
+ ```
31
+
32
+ レスポンスオブジェクト内にステータスコード、JSONをパースしたハッシュマップ、さらにレスポンス内容のオブジェクトが含まれています。
33
+
34
+ ## Settings
35
+
36
+ 設定はINIファイルに記述し、 Pokepay::Client のコンストラクタにファイルパスを指定します。
37
+
38
+ SDKプロジェクトルートに config.ini.sample というファイルがありますのでそれを元に必要な情報を記述してください。特に以下の情報は通信の安全性のため必要な項目です。これらはパートナー契約時にお渡ししているものです。
39
+
40
+ - CLIENT_ID: パートナーAPI クライアントID
41
+ - CLIENT_SECRET: パートナーAPI クライアント秘密鍵
42
+ - SSL_KEY_FILE: SSL秘密鍵ファイルパス
43
+ - SSL_CERT_FILE: SSL証明書ファイルパス
44
+
45
+ この他に接続先のサーバURL情報が必要です。
46
+
47
+ - API_BASE_URL: パートナーAPI サーバURL
48
+
49
+ また、この設定ファイルには認証に必要な情報が含まれるため、ファイルの管理・取り扱いに十分注意してください。
50
+
51
+ 設定ファイル記述例(config.ini.sample)
52
+
53
+ ```
54
+ CLIENT_ID = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
55
+ CLIENT_SECRET = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
56
+ API_BASE_URL = https://partnerapi-sandbox.pokepay.jp
57
+ SSL_KEY_FILE = /path/to/key.pem
58
+ SSL_CERT_FILE = /path/to/cert.pem
59
+ ```
60
+
61
+ ## Overview
62
+
63
+ ### APIリクエスト
64
+
65
+ Partner APIへの通信はリクエストオブジェクトを作り、Pokepay::Client.send メソッドに渡すことで行われます。リクエストクラスは名前空間 Pokepay::Request 以下に定義されています。
66
+
67
+ たとえば Pokepay::Request::SendEcho 送信した内容をそのまま返す処理です。
68
+
69
+ ```ruby
70
+ request = Pokepay::Request::SendEcho.new('hello')
71
+
72
+ response = client.send(request)
73
+ # => #<Pokepay::Response::Response 200 OK readbody=>
74
+ ```
75
+
76
+ 通信の結果として、レスポンスオブジェクトが得られます。これはステータスコードとレスポンスボディ、各レスポンスクラスのオブジェクトをインスタンス変数に持つオブジェクトです。
77
+
78
+ ```ruby
79
+ response.code
80
+ # => 200
81
+
82
+ response.body
83
+ # => {"status"=>"ok", "message"=>"hello"}
84
+
85
+ response.object
86
+ # => #<Pokepay::Response::Echo:0x000055fd7cc0db20 @message="hello">
87
+
88
+ response.object.message
89
+ # => "hello"
90
+ ```
91
+
92
+ エラーの場合は Net::HTTPBadRequest などのエラーレスポンスオブジェクトが返ります。エラーレスポンスもステータスコードとレスポンスボディを持ちます。
93
+
94
+ ```ruby
95
+ request = Pokepay::Request::SendEcho.new(-1)
96
+
97
+ response = client.send(request)
98
+ # => #<Net::HTTPBadRequest 400 Bad Request readbody=true>
99
+
100
+ response.code
101
+ # => 400
102
+
103
+ response.body
104
+ # => {"type"=>"invalid_parameters", "message"=>"Invalid parameters", "errors"=>{"invalid"=>["message"]}}
23
105
  ```
24
106
 
25
- # Run test
107
+ ## API Operations
108
+
109
+ ### 取引一覧を取得する
110
+
111
+ ```ruby
112
+ response = client.send(Pokepay::Request::ListTransactions.new(
113
+ {
114
+ # ページング
115
+ "page" => 1,
116
+ "per_page" => 50,
26
117
 
118
+ # フィルタオプション (すべて任意)
119
+ # 期間指定 (ISO8601形式の文字列)
120
+ "from" => "2019-01-01T00:00:00+09:00",
121
+ "to" => "2019-07-30T18:13:39+09:00",
122
+ # 検索オプション
123
+ "customer_id" => "xxxxxxxxxxxxxxxxx", # エンドユーザーID
124
+ "customer_name" => "福沢", # エンドユーザー名
125
+ "transaction_id" => "24bba30c......", # 取引ID
126
+ "shop_id" => "456a820b......", # 店舗ID
127
+ "terminal_id" => "d8023185......", # 端末ID
128
+ "organization" => "pocketchange", # 組織コード
129
+ "private_money" => "9ff644fc......", # マネーID
130
+ "is_modified" => "true", # キャンセルされた取引のみ検索するか
131
+ # 取引種別 (複数指定可)、チャージ=topup、支払い=payment
132
+ "types" => ["topup", "payment"],
133
+ }))
27
134
  ```
28
- $ bundle exec ruby test/pokepay_partner_ruby_sdk_test.rb
135
+
136
+ 成功したときは Pokepay::Response::Transaction を rows に含むページングオブジェクトを返します。
137
+ 取引一覧のような大量のレスポンスが返るエンドポイントでは、一度に取得する量を制限するためにページングされています。
138
+
139
+ #### 取引情報
140
+
141
+ 取引クラスは Pokepay::Response::Transaction で定義されています。
142
+
143
+ 取引オブジェクトのプロパティは以下のようになっています。
144
+
145
+ - id (String): 取引ID
146
+ - type (String): 取引種別 (チャージ=topup, 支払い=payment)
147
+ - is_modified (真理値): 返金された取引かどうか
148
+ - sender (Response\User): 送金者情報
149
+ - receiver (Response\User): 受取者情報
150
+ - sender_account (Response\Account): 送金口座情報
151
+ - receiver_account (Response\Account): 受取口座情報
152
+ - amount (Numeric): 決済総額 (マネー額 + ポイント額)
153
+ - money_amount (Numeric): 決済マネー額
154
+ - point_amount (Numeric): 決済ポイント額
155
+ - done_at (Time): 取引日時
156
+ - description (String): 取引説明文
157
+
158
+ `sender` と `receiver` には `Pokepay::Response::User` のオブジェクトです。 以下にプロパティを示します。
159
+
160
+ - id (String): ユーザー (または店舗) ID
161
+ - name (String): ユーザー (または店舗) 名
162
+ - is_merchant (真理値): 店舗ユーザーかどうか
163
+
164
+ `senderAccount` と `receiverAccount` は `Pokepay::Response::Account` のオブジェクトです。以下にプロパティを示します。
165
+
166
+ - id (String): 口座ID
167
+ - name (String): 口座名
168
+ - is_suspended (真理値): 口座が凍結されているかどうか
169
+ - private_money (Response\PrivateMoney): 設定マネー情報
170
+
171
+ `privateMoney` は `Pokepay::Response::PrivateMoney` のオブジェクトです。以下にプロパティを示します。
172
+
173
+ - id (String): マネーID
174
+ - name (String): マネー名
175
+ - unit (String): マネー単位 (例: 円)
176
+ - is_exclusive (真理値): 会員制のマネーかどうか
177
+ - description (String): マネー説明文
178
+ - max_balance (Numeric): 口座の上限金額
179
+ - transfer_limit (Numeric): マネーの取引上限額
180
+ - type (String): マネー種別 (自家型=own, 第三者型=third-party)
181
+ - expiration_type (String): 有効期限種別 (チャージ日時起算=static, 最終利用日時起算=last-update)
182
+
183
+ #### ページング
184
+
185
+ ページングクラスは Pokepay::Response::Pagination で定義されています。
186
+
187
+ ページングオブジェクトのプロパティは以下のようになっています。
188
+
189
+ - rows : 列挙するレスポンスクラスのオブジェクトの配列
190
+ - count : 全体の要素数
191
+ - pagination : 以下のインスタンス変数を持つオブジェクト
192
+ - current : 現在のページ位置(1からスタート)
193
+ - per_page : 1ページ当たりの要素数
194
+ - max_page : 最後のページ番号
195
+ - has_prev : 前ページを持つかどうかの真理値
196
+ - has_next : 次ページを持つかどうかの真理値
197
+
198
+ ### チャージする
199
+
200
+ ```ruby
201
+ shop_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # 店舗ID
202
+ customer_id = "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy" # エンドユーザーのID
203
+ private_money_id = "zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz" # 送るマネーのID
204
+ money_amount = 1000 # チャージマネー額
205
+ point_amount = 0 # チャージするポイント額
206
+ description = "初夏のチャージキャンペーン" # 取引履歴に表示する説明文
207
+
208
+ response = $client.send(Pokepay::Request::CreateTransaction.new(
209
+ shop_id, customer_id, private_money_id,
210
+ money_amount, point_amount, description))
29
211
  ```
212
+
213
+ 成功したときは Pokepay::Response::Transaction を持つレスポンスオブジェクトを返します。
@@ -1,3 +1,3 @@
1
1
  module Pokepay
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pokepay_partner_ruby_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi Imai
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-23 00:00:00.000000000 Z
11
+ date: 2019-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler