shopify_api 4.0.4 → 4.0.5

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
  SHA1:
3
- metadata.gz: 23955d9a8ee5d523632bcb12220cb5c366516346
4
- data.tar.gz: 0c2f364c901d280de601677340f045c7e77910c1
3
+ metadata.gz: be2ddfc285851f78ac986c70ebb82b79601fdbcf
4
+ data.tar.gz: 2e71f5b7c5c63cfc19ffd0822f114cf816df358d
5
5
  SHA512:
6
- metadata.gz: 7f749d13957df809a2b68814b66e9db6dee6144da7b85e25d7d6c42c03c0bffff05c9427b57b58a92a8410ee97009a8d965f67c42d7441a5a878f55e3f07e541
7
- data.tar.gz: e3e90a739fbea49071641aa89d677f63d3e9aed7ef6760218a8f26761fb5e468300a87bee1c905adf7adbf8459e27c5fbdf287fb32639f6aaf7bc8a11f580dfb
6
+ metadata.gz: c16a2590667b6b1ccccf1de2eed1cb00b1dae4858c4a99cb0325060e9c4ebfa50e9a52badea7a23a4264cec65f701cd2dfd6635097034bf9e1039fc4b10053fd
7
+ data.tar.gz: e5a2d83e326fb52ce98724152d67956d3c9bc8aa8cd9001aad4044c5da8fcfe8b90e818824656ec8d5cb44bd483cde9ccff1c7ec0bedca117afec11aafd1257a
data/.gitignore CHANGED
@@ -6,3 +6,4 @@ doc
6
6
  pkg
7
7
  .ruby-version
8
8
  *.lock
9
+ .idea
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == Version 4.0.5
2
+
3
+ * Added `pending`, `cancelled`, `accepted`, `declined` helper methods to `ShopifyAPI::ApplicationCharge`
4
+
1
5
  == Version 4.0.4
2
6
 
3
7
  * Fixed truthiness for order cancellations. Requests are now sent in the request body and as JSON
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ShopifyAPI
2
- VERSION = "4.0.4"
2
+ VERSION = "4.0.5"
3
3
  end
@@ -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
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-06-02 00:00:00.000000000 Z
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