shopify_api 4.0.4 → 4.0.5
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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG +4 -0
- data/lib/shopify_api/resources/application_charge.rb +6 -0
- data/lib/shopify_api/version.rb +1 -1
- data/test/application_charge_test.rb +79 -0
- data/test/fixtures/application_charge.json +16 -0
- data/test/fixtures/application_charges.json +57 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be2ddfc285851f78ac986c70ebb82b79601fdbcf
|
4
|
+
data.tar.gz: 2e71f5b7c5c63cfc19ffd0822f114cf816df358d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c16a2590667b6b1ccccf1de2eed1cb00b1dae4858c4a99cb0325060e9c4ebfa50e9a52badea7a23a4264cec65f701cd2dfd6635097034bf9e1039fc4b10053fd
|
7
|
+
data.tar.gz: e5a2d83e326fb52ce98724152d67956d3c9bc8aa8cd9001aad4044c5da8fcfe8b90e818824656ec8d5cb44bd483cde9ccff1c7ec0bedca117afec11aafd1257a
|
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
@@ -2,6 +2,12 @@ module ShopifyAPI
|
|
2
2
|
class ApplicationCharge < Base
|
3
3
|
undef_method :test
|
4
4
|
|
5
|
+
class << self
|
6
|
+
[:pending, :cancelled, :accepted, :declined].each do |status|
|
7
|
+
define_method(status) { (all || []).select { |c| c.status == status.to_s } }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
def activate
|
6
12
|
load_attributes_from_response(post(:activate))
|
7
13
|
end
|
data/lib/shopify_api/version.rb
CHANGED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ApplicationChargeTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_application_charge_create
|
6
|
+
fake "application_charges", :method => :post, :status => 201, :body => load_fixture('application_charge')
|
7
|
+
|
8
|
+
charge = ShopifyAPI::ApplicationCharge.create(
|
9
|
+
name: "iPod Cleaning",
|
10
|
+
price: 5.00,
|
11
|
+
return_url: "http://google.com"
|
12
|
+
)
|
13
|
+
|
14
|
+
assert_equal 'https://this-is-my-test-shop.myshopify.com/admin/charges/803742/confirm_application_charge?signature=BAhpA55DDA%3D%3D--55b44e274e438c619be4631c804abcbcb6ee915a', charge.confirmation_url
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_get_application_charge
|
18
|
+
fake "application_charges/803742", :method => :get, :status => 201, :body => load_fixture('application_charge')
|
19
|
+
|
20
|
+
charge = ShopifyAPI::ApplicationCharge.find(803742)
|
21
|
+
|
22
|
+
assert_equal "iPod Cleaning", charge.name
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_list_application_charges
|
26
|
+
fake "application_charges", :method => :get, :status => 201, :body => load_fixture('application_charges')
|
27
|
+
|
28
|
+
charges = ShopifyAPI::ApplicationCharge.find(:all)
|
29
|
+
|
30
|
+
assert_equal 4, charges.size
|
31
|
+
assert_equal "iPhone Case", charges.last.name
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_list_pending_application_charges
|
35
|
+
fake "application_charges", :method => :get, :status => 201, :body => load_fixture('application_charges')
|
36
|
+
|
37
|
+
pending_charges = ShopifyAPI::ApplicationCharge.pending
|
38
|
+
|
39
|
+
assert_equal 1, pending_charges.size
|
40
|
+
assert_equal "Screen Replacement", pending_charges.first.name
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_list_cancelled_application_charges
|
44
|
+
fake "application_charges", :method => :get, :status => 201, :body => load_fixture('application_charges')
|
45
|
+
|
46
|
+
cancelled_charges = ShopifyAPI::ApplicationCharge.cancelled
|
47
|
+
|
48
|
+
assert_equal 1, cancelled_charges.size
|
49
|
+
assert_equal "iPod Cleaning", cancelled_charges.first.name
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_list_accepted_application_charges
|
53
|
+
fake "application_charges", :method => :get, :status => 201, :body => load_fixture('application_charges')
|
54
|
+
|
55
|
+
accepted_charges = ShopifyAPI::ApplicationCharge.accepted
|
56
|
+
|
57
|
+
assert_equal 1, accepted_charges.size
|
58
|
+
assert_equal "iPhone Case", accepted_charges.first.name
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_list_declined_application_charges
|
62
|
+
fake "application_charges", :method => :get, :status => 201, :body => load_fixture('application_charges')
|
63
|
+
|
64
|
+
declined_charges = ShopifyAPI::ApplicationCharge.declined
|
65
|
+
|
66
|
+
assert_equal 1, declined_charges.size
|
67
|
+
assert_equal "Magic Mouse", declined_charges.first.name
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_activate_application_charge
|
71
|
+
fake "application_charges", :method => :get, :status => 201, :body => load_fixture('application_charges')
|
72
|
+
fake "application_charges/803740/activate", :method => :post, :status => 200, :body => "{}"
|
73
|
+
|
74
|
+
charge = ShopifyAPI::ApplicationCharge.accepted
|
75
|
+
|
76
|
+
assert charge.last.activate
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"application_charge": {
|
3
|
+
"api_client_id": 861378,
|
4
|
+
"created_at": "2015-07-10T15:03:51+10:00",
|
5
|
+
"id": 803742,
|
6
|
+
"name": "iPod Cleaning",
|
7
|
+
"price": "5.00",
|
8
|
+
"return_url": "http:\/\/google.com",
|
9
|
+
"status": "pending",
|
10
|
+
"test": null,
|
11
|
+
"updated_at": "2015-07-10T15:03:51+10:00",
|
12
|
+
"charge_type": null,
|
13
|
+
"decorated_return_url": "http:\/\/google.com?charge_id=803742",
|
14
|
+
"confirmation_url": "https://this-is-my-test-shop.myshopify.com\/admin\/charges\/803742\/confirm_application_charge?signature=BAhpA55DDA%3D%3D--55b44e274e438c619be4631c804abcbcb6ee915a"
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
{
|
2
|
+
"application_charges": [
|
3
|
+
{
|
4
|
+
"api_client_id": 861378,
|
5
|
+
"created_at": "2015-07-10T15:16:14+10:00",
|
6
|
+
"id": 803750,
|
7
|
+
"name": "Magic Mouse",
|
8
|
+
"price": "99.00",
|
9
|
+
"return_url": "http:\/\/google.com",
|
10
|
+
"status": "declined",
|
11
|
+
"test": null,
|
12
|
+
"updated_at": "2015-07-10T15:18:09+10:00",
|
13
|
+
"charge_type": null,
|
14
|
+
"decorated_return_url": "http:\/\/google.com?charge_id=803750"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"api_client_id": 861378,
|
18
|
+
"created_at": "2015-07-10T15:10:10+10:00",
|
19
|
+
"id": 803748,
|
20
|
+
"name": "Screen Replacement",
|
21
|
+
"price": "499.00",
|
22
|
+
"return_url": "http:\/\/google.com",
|
23
|
+
"status": "pending",
|
24
|
+
"test": null,
|
25
|
+
"updated_at": "2015-07-10T15:10:10+10:00",
|
26
|
+
"charge_type": null,
|
27
|
+
"decorated_return_url": "http:\/\/google.com?charge_id=803748",
|
28
|
+
"confirmation_url": "https:\/\/this-is-my-test-shop.myshopify.com\/admin\/charges\/803748\/confirm_application_charge?signature=BAhpA6RDDA%3D%3D--ef4769e2c1149de0ed19dee9ecddaa155baa7baf"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"api_client_id": 861378,
|
32
|
+
"created_at": "2015-07-10T15:03:51+10:00",
|
33
|
+
"id": 803742,
|
34
|
+
"name": "iPod Cleaning",
|
35
|
+
"price": "5.00",
|
36
|
+
"return_url": "http:\/\/google.com",
|
37
|
+
"status": "cancelled",
|
38
|
+
"test": null,
|
39
|
+
"updated_at": "2015-07-10T15:03:51+10:00",
|
40
|
+
"charge_type": null,
|
41
|
+
"decorated_return_url": "http:\/\/google.com?charge_id=803742"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"api_client_id": 861378,
|
45
|
+
"created_at": "2015-07-10T15:03:51+10:00",
|
46
|
+
"id": 803740,
|
47
|
+
"name": "iPhone Case",
|
48
|
+
"price": "23.00",
|
49
|
+
"return_url": "http:\/\/google.com",
|
50
|
+
"status": "accepted",
|
51
|
+
"test": null,
|
52
|
+
"updated_at": "2015-07-10T15:03:51+10:00",
|
53
|
+
"charge_type": null,
|
54
|
+
"decorated_return_url": "http:\/\/google.com?charge_id=803740"
|
55
|
+
}
|
56
|
+
]
|
57
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- shipit.rubygems.yml
|
191
191
|
- shopify_api.gemspec
|
192
192
|
- test/active_resource/json_errors_test.rb
|
193
|
+
- test/application_charge_test.rb
|
193
194
|
- test/article_test.rb
|
194
195
|
- test/asset_test.rb
|
195
196
|
- test/base_test.rb
|
@@ -200,6 +201,8 @@ files:
|
|
200
201
|
- test/customer_saved_search_test.rb
|
201
202
|
- test/customer_test.rb
|
202
203
|
- test/detailed_log_subscriber_test.rb
|
204
|
+
- test/fixtures/application_charge.json
|
205
|
+
- test/fixtures/application_charges.json
|
203
206
|
- test/fixtures/article.json
|
204
207
|
- test/fixtures/articles.json
|
205
208
|
- test/fixtures/asset.json
|