webpay 2.2.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/webpay.rb +1 -0
- data/lib/webpay/client.rb +1 -1
- data/lib/webpay/response_converter.rb +2 -0
- data/lib/webpay/shop.rb +73 -0
- data/lib/webpay/version.rb +1 -1
- data/spec/resources/shops/all.txt +122 -0
- data/spec/resources/shops/create.txt +54 -0
- data/spec/resources/shops/retrieve.txt +54 -0
- data/spec/resources/shops/update.txt +55 -0
- data/spec/webpay/shop_spec.rb +121 -0
- data/spec/webpay_spec.rb +5 -0
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 188092b3058c63d8eab3b701aa0e7ffcccbec5f4
|
4
|
+
data.tar.gz: cb6faf9a38e95164e1ca21142ea7ec81bb69335a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a29018c83c4bba873bd84f2c37dc0b42cac4abd8453559b7a09c399ef4e9f56a7739201e09abe43effc77a54065ae6d6b77966e952ac8b9d02f8a5d43128485
|
7
|
+
data.tar.gz: e4a6023906009fa1d357a1301021e7d77c93190683fead2d0d84b3c392f4f9afce4061d6ee2687e5262cfe177c3e23dd7339c18eb9bedce61c90a89101014b7c
|
data/README.md
CHANGED
@@ -44,3 +44,9 @@ See [WebPay Ruby API Document](https://webpay.jp/docs/api/ruby) for more details
|
|
44
44
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
45
45
|
4. Push to the branch (`git push origin my-new-feature`)
|
46
46
|
5. Create new Pull Request
|
47
|
+
|
48
|
+
## License
|
49
|
+
|
50
|
+
[The MIT License (MIT)](http://opensource.org/licenses/mit-license.html)
|
51
|
+
|
52
|
+
Copyright (c) 2013- WebPay.
|
data/lib/webpay.rb
CHANGED
@@ -20,6 +20,7 @@ module WebPay
|
|
20
20
|
autoload(:Customer, 'webpay/customer')
|
21
21
|
autoload(:Event, 'webpay/event')
|
22
22
|
autoload(:Token, 'webpay/token')
|
23
|
+
autoload(:Shop, 'webpay/shop')
|
23
24
|
autoload(:ResponseConverter, 'webpay/response_converter')
|
24
25
|
|
25
26
|
@api_base = 'https://api.webpay.jp'
|
data/lib/webpay/client.rb
CHANGED
@@ -53,7 +53,7 @@ module WebPay
|
|
53
53
|
define_method(method) do |url, *args|
|
54
54
|
begin
|
55
55
|
response = @conn.__send__(method, @api_version + url, *args)
|
56
|
-
rescue Faraday::Error::ClientError => e
|
56
|
+
rescue Faraday::Error::ClientError, URI::InvalidURIError => e
|
57
57
|
raise WebPay::APIConnectionError.faraday_error(e)
|
58
58
|
end
|
59
59
|
handle_response(response)
|
data/lib/webpay/shop.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
module WebPay
|
2
|
+
|
3
|
+
# Object for API response hash object with <code>hash['object'] = shop</code>
|
4
|
+
class Shop < Entity
|
5
|
+
install_class_operations :create, :retrieve, :all
|
6
|
+
|
7
|
+
# Attributes which can be updated and read by access.
|
8
|
+
# These attributes are sent on save if changed.
|
9
|
+
attr_accessor :read_attributes
|
10
|
+
|
11
|
+
# @return [String] Relative path to API root
|
12
|
+
# @api private
|
13
|
+
def self.path
|
14
|
+
'/shops'
|
15
|
+
end
|
16
|
+
|
17
|
+
# @api private
|
18
|
+
def initialize(attributes)
|
19
|
+
@read_attributes = {}
|
20
|
+
super(attributes)
|
21
|
+
end
|
22
|
+
|
23
|
+
# <code>object['key']=</code> is wrapper for <code>object.key =</code>.
|
24
|
+
# Method call style is recommended.
|
25
|
+
# @return [Object] Given value
|
26
|
+
def []=(key, value)
|
27
|
+
send("#{key}=", value)
|
28
|
+
end
|
29
|
+
|
30
|
+
# <code>object['key']</code> is wrapper for <code>object.key</code>.
|
31
|
+
# Method call style is recommended.
|
32
|
+
# @return [Object] The attribute's value
|
33
|
+
def [](key)
|
34
|
+
send(key)
|
35
|
+
end
|
36
|
+
|
37
|
+
[:description, :details].each do |attr|
|
38
|
+
define_method("#{attr}=") do |value|
|
39
|
+
@read_attributes[attr.to_s] = value
|
40
|
+
end
|
41
|
+
define_method("#{attr}") do
|
42
|
+
obj = @attributes[attr.to_s]
|
43
|
+
copyable = !(obj == nil || obj == true || obj == false || obj.is_a?(Symbol) || obj.is_a?(Integer))
|
44
|
+
@read_attributes[attr.to_s] ||= copyable ? obj.dup : obj
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Return a hash similar to the response from API.
|
49
|
+
# If an attribute's value is updated, the updated value is used.
|
50
|
+
# @return [Hash] a hash similar to the response from API
|
51
|
+
def to_hash
|
52
|
+
Hash[@attributes.merge(@read_attributes).map { |k, v| [k, v.is_a?(Entity) ? v.to_hash : v] }]
|
53
|
+
end
|
54
|
+
|
55
|
+
alias_method :to_h, :to_hash
|
56
|
+
|
57
|
+
# Send update request of modified attributes.
|
58
|
+
# description and details are modifiable.
|
59
|
+
# @return [Shop] this object with attributes updated
|
60
|
+
def save
|
61
|
+
changed_attributes = @read_attributes.select { |k,v| @attributes[k] != v }
|
62
|
+
update_attributes(WebPay.client.post(path, changed_attributes))
|
63
|
+
@read_attributes = {}
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [String] Relative path of instance to API root
|
68
|
+
# @api private
|
69
|
+
def path
|
70
|
+
"/shops/#{id}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/webpay/version.rb
CHANGED
@@ -0,0 +1,122 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-Ua-Compatible: IE=Edge
|
4
|
+
Etag: "b48ac5b36f03530f3aeb0ab8cf938776"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
X-Request-Id: 4649874c8b3784ddc5efceab0fc13974
|
7
|
+
X-Runtime: 0.045599
|
8
|
+
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-22)
|
9
|
+
Date: Sat, 05 Apr 2014 13:59:50 GMT
|
10
|
+
Content-Length: 3720
|
11
|
+
Connection: Keep-Alive
|
12
|
+
|
13
|
+
{
|
14
|
+
"object": "list",
|
15
|
+
"url": "/v1/shops",
|
16
|
+
"count": 7,
|
17
|
+
"data": [
|
18
|
+
{
|
19
|
+
"id": "sh_4hB3x19La1tr0Lu",
|
20
|
+
"object": "shop",
|
21
|
+
"livemode": false,
|
22
|
+
"status": "created",
|
23
|
+
"description": "Sample Shop",
|
24
|
+
"access_key": "shop_8Yp3sy4HberKgut6vy4Ss6FA",
|
25
|
+
"created": 1396706101,
|
26
|
+
"details": {
|
27
|
+
"url": "https://webpay.jp",
|
28
|
+
"name": "WebPay",
|
29
|
+
"name_alphabet": "WEBPAY",
|
30
|
+
"name_kana": "ウェブペイ",
|
31
|
+
"product": "クレジットカード決済API",
|
32
|
+
"pricing_url": "https://webpay.jp/pricing",
|
33
|
+
"commercial_law_url": "https://webpay.jp/company",
|
34
|
+
"price_min": "30",
|
35
|
+
"price_max": "50000",
|
36
|
+
"price_average": "4000",
|
37
|
+
"zipcode": "1410022",
|
38
|
+
"address": "東京都品川区東品川2丁目2-28 タチバナビル2F",
|
39
|
+
"address_kana": "トウキョウトシナガワクヒガシシナガワ2チョウメ2-28 タチバナビル2F",
|
40
|
+
"applicant_name": "曾川景介",
|
41
|
+
"applicant_name_kana": "ソガワケイスケ",
|
42
|
+
"applicant_email": "sowawa@webpay.jp",
|
43
|
+
"applicant_phone": "03-4589-4747",
|
44
|
+
"company_name": "ウェブペイ株式会社",
|
45
|
+
"company_name_kana": "ウェブペイカブシキガイシャ",
|
46
|
+
"company_phone": "03-4589-4747",
|
47
|
+
"company_found_date": "20130601",
|
48
|
+
"company_president_name": "久保渓",
|
49
|
+
"company_president_name_kana": "クボケイ"
|
50
|
+
},
|
51
|
+
"statement_descriptor": null,
|
52
|
+
"card_types_supported": [
|
53
|
+
"Visa",
|
54
|
+
"American Express",
|
55
|
+
"MasterCard",
|
56
|
+
"JCB",
|
57
|
+
"Diners Club"
|
58
|
+
]
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"id": "sh_4hBfnVcoNdRw0Jj",
|
62
|
+
"object": "shop",
|
63
|
+
"livemode": false,
|
64
|
+
"status": "created",
|
65
|
+
"description": "最新の店子",
|
66
|
+
"access_key": "shop_1Qy9XO2G56ru4DedFFgjr3vZ",
|
67
|
+
"created": 1396705255,
|
68
|
+
"details": {
|
69
|
+
"url": "https://new.example.com",
|
70
|
+
"name": "WebPay",
|
71
|
+
"name_alphabet": "WEBPAY",
|
72
|
+
"name_kana": "ウェブペイ",
|
73
|
+
"product": "クレジットカード決済API",
|
74
|
+
"pricing_url": "https://webpay.jp/pricing",
|
75
|
+
"commercial_law_url": "https://webpay.jp/company",
|
76
|
+
"price_min": "30",
|
77
|
+
"price_max": "50000",
|
78
|
+
"price_average": "4000",
|
79
|
+
"zipcode": "1410022",
|
80
|
+
"address": "東京都品川区東品川2丁目2-28 タチバナビル2F",
|
81
|
+
"address_kana": "トウキョウトシナガワクヒガシシナガワ2チョウメ2-28 タチバナビル2F",
|
82
|
+
"applicant_name": "曾川景介",
|
83
|
+
"applicant_name_kana": "ソガワケイスケ",
|
84
|
+
"applicant_email": "sowawa@webpay.jp",
|
85
|
+
"applicant_phone": "03-4589-4747",
|
86
|
+
"company_name": "ウェブペイ株式会社",
|
87
|
+
"company_name_kana": "ウェブペイカブシキガイシャ",
|
88
|
+
"company_phone": "03-4589-4747",
|
89
|
+
"company_found_date": "20130601",
|
90
|
+
"company_president_name": "久保渓",
|
91
|
+
"company_president_name_kana": "クボケイ",
|
92
|
+
"company_president_birth_date": "19850810"
|
93
|
+
},
|
94
|
+
"statement_descriptor": null,
|
95
|
+
"card_types_supported": [
|
96
|
+
"Visa",
|
97
|
+
"American Express",
|
98
|
+
"MasterCard",
|
99
|
+
"JCB",
|
100
|
+
"Diners Club"
|
101
|
+
]
|
102
|
+
},
|
103
|
+
{
|
104
|
+
"id": "sh_4hB4JjdP11YT9Qs",
|
105
|
+
"object": "shop",
|
106
|
+
"livemode": false,
|
107
|
+
"status": "created",
|
108
|
+
"description": "test4",
|
109
|
+
"access_key": "shop_5y26Ulc6w5bAgb28jM1Nv4RL",
|
110
|
+
"created": 1396705607,
|
111
|
+
"details": null,
|
112
|
+
"statement_descriptor": null,
|
113
|
+
"card_types_supported": [
|
114
|
+
"Visa",
|
115
|
+
"American Express",
|
116
|
+
"MasterCard",
|
117
|
+
"JCB",
|
118
|
+
"Diners Club"
|
119
|
+
]
|
120
|
+
}
|
121
|
+
]
|
122
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-Ua-Compatible: IE=Edge
|
4
|
+
Etag: "1cb9c156621a509dbcd11f65655eac77"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
X-Request-Id: cb54cd8a7a140ab9408e8e1fa45707cb
|
7
|
+
X-Runtime: 0.381446
|
8
|
+
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-22)
|
9
|
+
Date: Sat, 05 Apr 2014 13:55:01 GMT
|
10
|
+
Content-Length: 1404
|
11
|
+
Connection: Keep-Alive
|
12
|
+
|
13
|
+
{
|
14
|
+
"id": "sh_4hB3x19La1tr0Lu",
|
15
|
+
"object": "shop",
|
16
|
+
"livemode": false,
|
17
|
+
"status": "created",
|
18
|
+
"description": "Sample Shop",
|
19
|
+
"access_key": "shop_8Yp3sy4HberKgut6vy4Ss6FA",
|
20
|
+
"created": 1396706101,
|
21
|
+
"details": {
|
22
|
+
"url": "https://webpay.jp",
|
23
|
+
"name": "WebPay",
|
24
|
+
"name_alphabet": "WEBPAY",
|
25
|
+
"name_kana": "ウェブペイ",
|
26
|
+
"product": "クレジットカード決済API",
|
27
|
+
"pricing_url": "https://webpay.jp/pricing",
|
28
|
+
"commercial_law_url": "https://webpay.jp/company",
|
29
|
+
"price_min": "30",
|
30
|
+
"price_max": "50000",
|
31
|
+
"price_average": "4000",
|
32
|
+
"zipcode": "1410022",
|
33
|
+
"address": "東京都品川区東品川2丁目2-28 タチバナビル2F",
|
34
|
+
"address_kana": "トウキョウトシナガワクヒガシシナガワ2チョウメ2-28 タチバナビル2F",
|
35
|
+
"applicant_name": "曾川景介",
|
36
|
+
"applicant_name_kana": "ソガワケイスケ",
|
37
|
+
"applicant_email": "sowawa@webpay.jp",
|
38
|
+
"applicant_phone": "03-4589-4747",
|
39
|
+
"company_name": "ウェブペイ株式会社",
|
40
|
+
"company_name_kana": "ウェブペイカブシキガイシャ",
|
41
|
+
"company_phone": "03-4589-4747",
|
42
|
+
"company_found_date": "20130601",
|
43
|
+
"company_president_name": "久保渓",
|
44
|
+
"company_president_name_kana": "クボケイ"
|
45
|
+
},
|
46
|
+
"statement_descriptor": null,
|
47
|
+
"card_types_supported": [
|
48
|
+
"Visa",
|
49
|
+
"American Express",
|
50
|
+
"MasterCard",
|
51
|
+
"JCB",
|
52
|
+
"Diners Club"
|
53
|
+
]
|
54
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-Ua-Compatible: IE=Edge
|
4
|
+
Etag: "fbc3a10c62e15c8be01d2cfade7f46c6"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
X-Request-Id: eed408fc7f696cd877846b8b3d03dcde
|
7
|
+
X-Runtime: 0.008473
|
8
|
+
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-22)
|
9
|
+
Date: Sat, 05 Apr 2014 13:45:40 GMT
|
10
|
+
Content-Length: 1395
|
11
|
+
Connection: Keep-Alive
|
12
|
+
|
13
|
+
{
|
14
|
+
"id": "sh_4hBfnVcoNdRw0Jj",
|
15
|
+
"object": "shop",
|
16
|
+
"livemode": false,
|
17
|
+
"status": "created",
|
18
|
+
"description": null,
|
19
|
+
"access_key": "shop_1Qy9XO2G56ru4DedFFgjr3vZ",
|
20
|
+
"created": 1396705255,
|
21
|
+
"details": {
|
22
|
+
"url": "https://webpay.jp",
|
23
|
+
"name": "WebPay",
|
24
|
+
"name_alphabet": "WEBPAY",
|
25
|
+
"name_kana": "ウェブペイ",
|
26
|
+
"product": "クレジットカード決済API",
|
27
|
+
"pricing_url": "https://webpay.jp/pricing",
|
28
|
+
"commercial_law_url": "https://webpay.jp/company",
|
29
|
+
"price_min": "30",
|
30
|
+
"price_max": "50000",
|
31
|
+
"price_average": "4000",
|
32
|
+
"zipcode": "1410022",
|
33
|
+
"address": "東京都品川区東品川2丁目2-28 タチバナビル2F",
|
34
|
+
"address_kana": "トウキョウトシナガワクヒガシシナガワ2チョウメ2-28 タチバナビル2F",
|
35
|
+
"applicant_name": "曾川景介",
|
36
|
+
"applicant_name_kana": "ソガワケイスケ",
|
37
|
+
"applicant_email": "sowawa@webpay.jp",
|
38
|
+
"applicant_phone": "03-4589-4747",
|
39
|
+
"company_name": "ウェブペイ株式会社",
|
40
|
+
"company_name_kana": "ウェブペイカブシキガイシャ",
|
41
|
+
"company_phone": "03-4589-4747",
|
42
|
+
"company_found_date": "20130601",
|
43
|
+
"company_president_name": "久保渓",
|
44
|
+
"company_president_name_kana": "クボケイ"
|
45
|
+
},
|
46
|
+
"statement_descriptor": null,
|
47
|
+
"card_types_supported": [
|
48
|
+
"Visa",
|
49
|
+
"American Express",
|
50
|
+
"MasterCard",
|
51
|
+
"JCB",
|
52
|
+
"Diners Club"
|
53
|
+
]
|
54
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-Ua-Compatible: IE=Edge
|
4
|
+
Etag: "dddb6342b15c871b2283b7e468528dd9"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
X-Request-Id: 5c8a469c04d4d4361e646584c52df499
|
7
|
+
X-Runtime: 0.395131
|
8
|
+
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-22)
|
9
|
+
Date: Sat, 05 Apr 2014 13:50:05 GMT
|
10
|
+
Content-Length: 1462
|
11
|
+
Connection: Keep-Alive
|
12
|
+
|
13
|
+
{
|
14
|
+
"id": "sh_4hBfnVcoNdRw0Jj",
|
15
|
+
"object": "shop",
|
16
|
+
"livemode": false,
|
17
|
+
"status": "created",
|
18
|
+
"description": "最新の店子",
|
19
|
+
"access_key": "shop_1Qy9XO2G56ru4DedFFgjr3vZ",
|
20
|
+
"created": 1396705255,
|
21
|
+
"details": {
|
22
|
+
"url": "https://new.example.com",
|
23
|
+
"name": "WebPay",
|
24
|
+
"name_alphabet": "WEBPAY",
|
25
|
+
"name_kana": "ウェブペイ",
|
26
|
+
"product": "クレジットカード決済API",
|
27
|
+
"pricing_url": "https://webpay.jp/pricing",
|
28
|
+
"commercial_law_url": "https://webpay.jp/company",
|
29
|
+
"price_min": "30",
|
30
|
+
"price_max": "50000",
|
31
|
+
"price_average": "4000",
|
32
|
+
"zipcode": "1410022",
|
33
|
+
"address": "東京都品川区東品川2丁目2-28 タチバナビル2F",
|
34
|
+
"address_kana": "トウキョウトシナガワクヒガシシナガワ2チョウメ2-28 タチバナビル2F",
|
35
|
+
"applicant_name": "曾川景介",
|
36
|
+
"applicant_name_kana": "ソガワケイスケ",
|
37
|
+
"applicant_email": "sowawa@webpay.jp",
|
38
|
+
"applicant_phone": "03-4589-4747",
|
39
|
+
"company_name": "ウェブペイ株式会社",
|
40
|
+
"company_name_kana": "ウェブペイカブシキガイシャ",
|
41
|
+
"company_phone": "03-4589-4747",
|
42
|
+
"company_found_date": "20130601",
|
43
|
+
"company_president_name": "久保渓",
|
44
|
+
"company_president_name_kana": "クボケイ",
|
45
|
+
"company_president_birth_date": "19850810"
|
46
|
+
},
|
47
|
+
"statement_descriptor": null,
|
48
|
+
"card_types_supported": [
|
49
|
+
"Visa",
|
50
|
+
"American Express",
|
51
|
+
"MasterCard",
|
52
|
+
"JCB",
|
53
|
+
"Diners Club"
|
54
|
+
]
|
55
|
+
}
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
describe WebPay::Shop do
|
4
|
+
let(:details) {
|
5
|
+
{
|
6
|
+
"url"=>"https://webpay.jp",
|
7
|
+
"name"=>"WebPay",
|
8
|
+
"name_alphabet"=>"WEBPAY",
|
9
|
+
"name_kana"=>"ウェブペイ",
|
10
|
+
"product"=>"クレジットカード決済API",
|
11
|
+
"pricing_url"=>"https://webpay.jp/pricing",
|
12
|
+
"commercial_law_url"=>"https://webpay.jp/company",
|
13
|
+
"price_min"=>"30",
|
14
|
+
"price_max"=>"50000",
|
15
|
+
"price_average"=>"4000",
|
16
|
+
"zipcode"=>"1410022",
|
17
|
+
"address"=>"東京都品川区東品川2丁目2-28 タチバナビル2F",
|
18
|
+
"address_kana"=>"トウキョウトシナガワクヒガシシナガワ2チョウメ2-28 タチバナビル2F",
|
19
|
+
"applicant_name"=>"曾川景介",
|
20
|
+
"applicant_name_kana"=>"ソガワケイスケ",
|
21
|
+
"applicant_email"=>"sowawa@webpay.jp",
|
22
|
+
"applicant_phone"=>"03-4589-4747",
|
23
|
+
"company_name"=>"ウェブペイ株式会社",
|
24
|
+
"company_name_kana"=>"ウェブペイカブシキガイシャ",
|
25
|
+
"company_phone"=>"03-4589-4747",
|
26
|
+
"company_found_date"=>"20130601",
|
27
|
+
"company_president_name"=>"久保渓",
|
28
|
+
"company_president_name_kana"=>"クボケイ"
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
describe '.create' do
|
33
|
+
let(:params) { {:description => 'Sample Shop', :details => details} }
|
34
|
+
before do
|
35
|
+
stub_post_request('/shops', 'shops/create', params)
|
36
|
+
end
|
37
|
+
subject(:shop) { described_class.create(params)}
|
38
|
+
|
39
|
+
its(:id) { should eq 'sh_4hB3x19La1tr0Lu' }
|
40
|
+
its(:object) { should eq 'shop' }
|
41
|
+
its(:livemode) { should eq false }
|
42
|
+
its(:status) { should eq 'created' }
|
43
|
+
its(:description) { should eq "Sample Shop" }
|
44
|
+
its(:access_key) { should eq 'shop_8Yp3sy4HberKgut6vy4Ss6FA' }
|
45
|
+
its(:created) { should eq 1396706101 }
|
46
|
+
it { expect(shop.details).to eq details }
|
47
|
+
it { expect(shop.details['url']).to eq 'https://webpay.jp' }
|
48
|
+
its(:card_types_supported) { should eq ["Visa", "American Express", "MasterCard", "JCB", "Diners Club"] }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '.retrieve' do
|
52
|
+
let(:id) { 'sh_4hBfnVcoNdRw0Jj' }
|
53
|
+
before do
|
54
|
+
stub_get_request("/shops/#{id}", 'shops/retrieve')
|
55
|
+
end
|
56
|
+
|
57
|
+
subject(:shop) { described_class.retrieve(id) }
|
58
|
+
its(:id) { should eq id }
|
59
|
+
it { expect(shop.details).to eq details }
|
60
|
+
it { expect(shop.details['url']).to eq 'https://webpay.jp' }
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '.all' do
|
64
|
+
before do
|
65
|
+
stub_get_request("/shops?count=3&offset=0&created[gt]=1378000000", 'shops/all')
|
66
|
+
end
|
67
|
+
|
68
|
+
subject(:list) { described_class.all(count: 3, offset: 0, created: { gt: 1378000000 }) }
|
69
|
+
its(:url) { should eq '/v1/shops' }
|
70
|
+
its(:count) { should eq 7 }
|
71
|
+
it 'data.first.description' do
|
72
|
+
expect(list.data.first.description).to eq 'Sample Shop'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#save' do
|
77
|
+
let(:id) { 'sh_4hBfnVcoNdRw0Jj' }
|
78
|
+
let(:description) { '最新の店子' }
|
79
|
+
|
80
|
+
context 'details is changed' do
|
81
|
+
let(:updated_details) { details.merge('url' => 'https://new.example.com') }
|
82
|
+
before do
|
83
|
+
stub_get_request("/shops/#{id}", 'shops/retrieve')
|
84
|
+
stub_post_request("/shops/#{id}", 'shops/update', description: description, details: updated_details)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should update details of the retrieved shop' do
|
88
|
+
shop = described_class.retrieve(id)
|
89
|
+
shop.description = description
|
90
|
+
shop.details['url'] = 'https://new.example.com'
|
91
|
+
shop.save
|
92
|
+
|
93
|
+
expect(shop.description).to eq description
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'details is not changed' do
|
98
|
+
before do
|
99
|
+
stub_get_request("/shops/#{id}", 'shops/retrieve')
|
100
|
+
stub_post_request("/shops/#{id}", 'shops/update', description: description)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should update description of the retrieved shop' do
|
104
|
+
shop = described_class.retrieve(id)
|
105
|
+
shop.description = description
|
106
|
+
shop.save
|
107
|
+
|
108
|
+
expect(shop.description).to eq description
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when description is nil' do
|
114
|
+
it 'should return nil' do
|
115
|
+
shop = WebPay::Shop.new(description: nil)
|
116
|
+
expect(shop.description).to eq nil
|
117
|
+
shop.description = 'new description'
|
118
|
+
expect(shop.description).to eq 'new description'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/spec/webpay_spec.rb
CHANGED
@@ -32,4 +32,9 @@ describe WebPay do
|
|
32
32
|
its(:param) { should eq 'id' }
|
33
33
|
its(:message) { should eq '該当する顧客がありません: cus_eS6dGfa8BeUlbS' }
|
34
34
|
end
|
35
|
+
|
36
|
+
it 'should handle invalid URL as ApiConnectionError' do
|
37
|
+
expect { WebPay::Charge.retrieve('ch_aaaaxxxx 2014-04-04') }.
|
38
|
+
to raise_error(WebPay::APIConnectionError, 'Connection with WebPay API server failed. bad URI(is not URI?): /v1/charges/ch_aaaaxxxx 2014-04-04')
|
39
|
+
end
|
35
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- webpay
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- lib/webpay/event.rb
|
139
139
|
- lib/webpay/operations.rb
|
140
140
|
- lib/webpay/response_converter.rb
|
141
|
+
- lib/webpay/shop.rb
|
141
142
|
- lib/webpay/token.rb
|
142
143
|
- lib/webpay/version.rb
|
143
144
|
- lib/webpay/webpay_error.rb
|
@@ -165,6 +166,10 @@ files:
|
|
165
166
|
- spec/resources/errors/unknown_api_error.txt
|
166
167
|
- spec/resources/events/all_with_type.txt
|
167
168
|
- spec/resources/events/retrieve.txt
|
169
|
+
- spec/resources/shops/all.txt
|
170
|
+
- spec/resources/shops/create.txt
|
171
|
+
- spec/resources/shops/retrieve.txt
|
172
|
+
- spec/resources/shops/update.txt
|
168
173
|
- spec/resources/tokens/create.txt
|
169
174
|
- spec/resources/tokens/retrieve.txt
|
170
175
|
- spec/spec_helper.rb
|
@@ -172,6 +177,7 @@ files:
|
|
172
177
|
- spec/webpay/charge_spec.rb
|
173
178
|
- spec/webpay/customer_spec.rb
|
174
179
|
- spec/webpay/event_spec.rb
|
180
|
+
- spec/webpay/shop_spec.rb
|
175
181
|
- spec/webpay/token_spec.rb
|
176
182
|
- spec/webpay/webpay_error_spec.rb
|
177
183
|
- spec/webpay_spec.rb
|
@@ -225,6 +231,10 @@ test_files:
|
|
225
231
|
- spec/resources/errors/unknown_api_error.txt
|
226
232
|
- spec/resources/events/all_with_type.txt
|
227
233
|
- spec/resources/events/retrieve.txt
|
234
|
+
- spec/resources/shops/all.txt
|
235
|
+
- spec/resources/shops/create.txt
|
236
|
+
- spec/resources/shops/retrieve.txt
|
237
|
+
- spec/resources/shops/update.txt
|
228
238
|
- spec/resources/tokens/create.txt
|
229
239
|
- spec/resources/tokens/retrieve.txt
|
230
240
|
- spec/spec_helper.rb
|
@@ -232,6 +242,7 @@ test_files:
|
|
232
242
|
- spec/webpay/charge_spec.rb
|
233
243
|
- spec/webpay/customer_spec.rb
|
234
244
|
- spec/webpay/event_spec.rb
|
245
|
+
- spec/webpay/shop_spec.rb
|
235
246
|
- spec/webpay/token_spec.rb
|
236
247
|
- spec/webpay/webpay_error_spec.rb
|
237
248
|
- spec/webpay_spec.rb
|