passworks 0.0.2 → 0.0.3
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/.travis.yml +8 -0
- data/CHANGELOG.md +10 -0
- data/lib/passworks/client.rb +1 -2
- data/lib/passworks/collection_proxy.rb +1 -1
- data/lib/passworks/pass_resource.rb +3 -2
- data/lib/passworks/response.rb +6 -2
- data/lib/passworks/version.rb +1 -1
- data/passworks.gemspec +1 -0
- data/spec/.DS_Store +0 -0
- data/spec/assets_spec.rb +48 -0
- data/spec/coupons_spec.rb +60 -0
- data/spec/passworks_spec.rb +7 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/.DS_Store +0 -0
- data/spec/support/assets/logo.png +0 -0
- data/spec/support/vcr_setup.rb +8 -0
- metadata +35 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f8e460863f22f0cf87d9d704464f8e6f0676aae
|
4
|
+
data.tar.gz: b79ca3099d9c6dfa1b619c9a089d72924fa0e037
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ab1e5aadfc12791813cd5343991e057470a74c4be50ff7b807cea2265657e19573248ae517594b5f510c38b975d43b7debad98eb1e3782d063e76cc2771422a
|
7
|
+
data.tar.gz: 15fe3347b92715aa19dd2486ebe0423ab39a40f97e767c0d35642303c6c14e6c2326737b8a4e5951a532691950547e7edd126e3496104c648b594a6e873dead9
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,16 @@
|
|
3
3
|
This file is a manually maintained list of changes for each release. Feel free to add your
|
4
4
|
changes here when sending pull requests. Also send corrections if you spot any mistakes.
|
5
5
|
|
6
|
+
## v0.0.3 (2015-01-16)
|
7
|
+
* Bug fix: Missing 'event_tickets' namespace for from client
|
8
|
+
* Bug fix: Passworks::Response#ok? now returning correct information
|
9
|
+
* Feature: Implemented custom push message in the PassResource#push via :push_message attribute
|
10
|
+
```ruby
|
11
|
+
# @pass is a PassResource instance that maps to a pass in the system
|
12
|
+
@pass.push({push_message: "hello world"})
|
13
|
+
```
|
14
|
+
|
15
|
+
|
6
16
|
## v0.0.2 (2014-10-31)
|
7
17
|
* Bug fix: Fixed typo in the code that prevent creating an Asset
|
8
18
|
|
data/lib/passworks/client.rb
CHANGED
@@ -35,8 +35,7 @@ module Passworks
|
|
35
35
|
# @!method generics
|
36
36
|
# Allows to to access the Generic API
|
37
37
|
# @return [Passworks::RequestProxy]
|
38
|
-
|
39
|
-
%w(assets boarding_passes store_cards coupons generics).each do |collection_name|
|
38
|
+
%w(assets boarding_passes store_cards coupons event_tickets generics).each do |collection_name|
|
40
39
|
define_method(collection_name) do
|
41
40
|
Passworks::RequestProxy.new(self, collection_name, nil)
|
42
41
|
end
|
@@ -14,8 +14,9 @@ module Passworks
|
|
14
14
|
|
15
15
|
# Sends a push notification to all clients with this pass installed
|
16
16
|
# @return [Boolean] True in case the pass
|
17
|
-
def push
|
18
|
-
|
17
|
+
def push(options={})
|
18
|
+
options = { body: options } unless options.empty?
|
19
|
+
client.post("#{collection_name}/#{collection_uuid}/passes/#{id}/push", options).ok?
|
19
20
|
end
|
20
21
|
|
21
22
|
# Updates the {PassResource} and returns the updated instance
|
data/lib/passworks/response.rb
CHANGED
@@ -30,11 +30,15 @@ module Passworks
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def http_status
|
33
|
-
@response
|
33
|
+
@response.status
|
34
|
+
end
|
35
|
+
|
36
|
+
def response
|
37
|
+
@response
|
34
38
|
end
|
35
39
|
|
36
40
|
def ok?
|
37
|
-
|
41
|
+
@response.success?
|
38
42
|
end
|
39
43
|
|
40
44
|
def headers
|
data/lib/passworks/version.rb
CHANGED
data/passworks.gemspec
CHANGED
data/spec/.DS_Store
ADDED
Binary file
|
data/spec/assets_spec.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.expand_path 'spec_helper.rb', __dir__
|
2
|
+
|
3
|
+
describe 'Assets', :vcr do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Passworks.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "calling #assets method from the client should return RequestProxy" do
|
10
|
+
@client.assets.must_be_instance_of Passworks::RequestProxy
|
11
|
+
end
|
12
|
+
|
13
|
+
it "fetching all assets should return CollectionProxy" do
|
14
|
+
@client.assets.all.must_be_instance_of Passworks::CollectionProxy
|
15
|
+
end
|
16
|
+
|
17
|
+
it "all.to_a should return an array" do
|
18
|
+
@client.assets.all(per_page: 1).to_a.must_be_instance_of Array
|
19
|
+
end
|
20
|
+
|
21
|
+
it "create and asset" do
|
22
|
+
# check if ok
|
23
|
+
asset = @client.assets.create({
|
24
|
+
file: test_asset_path("logo.png"),
|
25
|
+
asset_type: 'logo'
|
26
|
+
})
|
27
|
+
|
28
|
+
asset.must_be_instance_of Passworks::AssetResource
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'fetch the asset using #find' do
|
32
|
+
asset ||= @client.assets.create({
|
33
|
+
file: test_asset_path("logo.png"),
|
34
|
+
asset_type: 'logo'
|
35
|
+
})
|
36
|
+
|
37
|
+
# try to fetch the asset
|
38
|
+
fetched_asset = @client.assets.find(asset.id)
|
39
|
+
|
40
|
+
# fetched asset can't be nil
|
41
|
+
fetched_asset.wont_be_nil
|
42
|
+
|
43
|
+
# must must be same as
|
44
|
+
asset.id.must_equal fetched_asset.id
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.expand_path 'spec_helper.rb', __dir__
|
2
|
+
|
3
|
+
describe 'Coupons', :vcr do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Passworks.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "calling #coupons method from the client should return a RequestProxy" do
|
10
|
+
@client.coupons.must_be_instance_of Passworks::RequestProxy
|
11
|
+
end
|
12
|
+
|
13
|
+
it "fetching #all coupons should return a CollectionProxy" do
|
14
|
+
@client.coupons.all.must_be_instance_of Passworks::CollectionProxy
|
15
|
+
end
|
16
|
+
|
17
|
+
it "#all.to_a should return an array" do
|
18
|
+
@client.coupons.all(per_page: 1).to_a.must_be_instance_of Array
|
19
|
+
end
|
20
|
+
|
21
|
+
it "#create an coupon from RequestProxy object" do
|
22
|
+
|
23
|
+
coupon = @client.coupons.create({
|
24
|
+
name: "New coupon #{Time.now.to_s}",
|
25
|
+
icon_id: icon_asset_instance.id
|
26
|
+
})
|
27
|
+
|
28
|
+
coupon.must_be_instance_of Passworks::CampaignResource
|
29
|
+
|
30
|
+
# if you created a coupon campaing the return collection should be a "coupons"
|
31
|
+
coupon.collection_name.must_equal "coupons"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "#passes on a CampaignResource should return RequestProxy and #all should return an Passworks::CollectionProxy" do
|
35
|
+
|
36
|
+
coupon = @client.coupons.create({
|
37
|
+
name: "New coupon #{Time.now.to_s}",
|
38
|
+
icon_id: icon_asset_instance.id
|
39
|
+
})
|
40
|
+
|
41
|
+
coupon.passes.must_be_instance_of Passworks::RequestProxy
|
42
|
+
|
43
|
+
coupon.passes.all(per_page: 1).must_be_instance_of Passworks::CollectionProxy
|
44
|
+
end
|
45
|
+
|
46
|
+
it "create a pass for an coupon campaign" do
|
47
|
+
coupon = @client.coupons.create({
|
48
|
+
name: "New coupon #{Time.now.to_s}",
|
49
|
+
icon_id: icon_asset_instance.id
|
50
|
+
})
|
51
|
+
|
52
|
+
coupon_pass = coupon.passes.create()
|
53
|
+
|
54
|
+
coupon_pass.must_be_instance_of Passworks::PassResource
|
55
|
+
|
56
|
+
coupon_pass.collection_name.must_equal "coupons"
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
ENV['RACK_ENV'] = 'test'
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'minitest/pride'
|
5
|
+
require 'minitest-vcr'
|
6
|
+
require 'webmock/minitest'
|
7
|
+
|
8
|
+
require 'pry'
|
9
|
+
require 'pry-byebug'
|
10
|
+
|
11
|
+
MinitestVcr::Spec.configure!
|
12
|
+
|
13
|
+
require File.expand_path './support/vcr_setup.rb', __dir__
|
14
|
+
|
15
|
+
require File.expand_path '../lib/passworks.rb' , __dir__
|
16
|
+
|
17
|
+
Passworks.configure do |config|
|
18
|
+
config.api_username = ENV['PASSWORKS_API_USERNAME']
|
19
|
+
config.api_secret = ENV['PASSWORKS_API_SECRET']
|
20
|
+
config.endpoint = 'http://api.passworks.git:3000'
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_asset_path(file)
|
24
|
+
File.expand_path "./support/assets/#{file}", __dir__
|
25
|
+
end
|
26
|
+
|
27
|
+
def icon_asset_instance
|
28
|
+
@icon_asset_instance ||= @client.assets.create({
|
29
|
+
file: test_asset_path("logo.png"),
|
30
|
+
asset_type: 'icon'
|
31
|
+
})
|
32
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'vcr'
|
2
|
+
|
3
|
+
VCR.configure do |c|
|
4
|
+
c.cassette_library_dir = 'spec/cassettes'
|
5
|
+
c.hook_into :webmock
|
6
|
+
c.filter_sensitive_data('PASSWORKS_API_USERNAME'){ ENV['PASSWORKS_API_USERNAME'] }
|
7
|
+
c.filter_sensitive_data('PASSWORKS_API_SECRET'){ ENV['PASSWORKS_API_SECRET'] }
|
8
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: passworks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis Mendes
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-01-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
@@ -138,6 +138,20 @@ dependencies:
|
|
138
138
|
- - '>='
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0'
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: minitest-vcr
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
type: :development
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
141
155
|
description: Provides a simple interface to Passworks API
|
142
156
|
email:
|
143
157
|
- luis@passworks.io
|
@@ -148,6 +162,7 @@ extensions: []
|
|
148
162
|
extra_rdoc_files: []
|
149
163
|
files:
|
150
164
|
- .gitignore
|
165
|
+
- .travis.yml
|
151
166
|
- CHANGELOG.md
|
152
167
|
- Gemfile
|
153
168
|
- README.md
|
@@ -183,6 +198,14 @@ files:
|
|
183
198
|
- lib/passworks/response.rb
|
184
199
|
- lib/passworks/version.rb
|
185
200
|
- passworks.gemspec
|
201
|
+
- spec/.DS_Store
|
202
|
+
- spec/assets_spec.rb
|
203
|
+
- spec/coupons_spec.rb
|
204
|
+
- spec/passworks_spec.rb
|
205
|
+
- spec/spec_helper.rb
|
206
|
+
- spec/support/.DS_Store
|
207
|
+
- spec/support/assets/logo.png
|
208
|
+
- spec/support/vcr_setup.rb
|
186
209
|
homepage: https://www.passworks.io
|
187
210
|
licenses:
|
188
211
|
- MIT
|
@@ -207,4 +230,13 @@ rubygems_version: 2.2.2
|
|
207
230
|
signing_key:
|
208
231
|
specification_version: 4
|
209
232
|
summary: Passworks API client
|
210
|
-
test_files:
|
233
|
+
test_files:
|
234
|
+
- spec/.DS_Store
|
235
|
+
- spec/assets_spec.rb
|
236
|
+
- spec/coupons_spec.rb
|
237
|
+
- spec/passworks_spec.rb
|
238
|
+
- spec/spec_helper.rb
|
239
|
+
- spec/support/.DS_Store
|
240
|
+
- spec/support/assets/logo.png
|
241
|
+
- spec/support/vcr_setup.rb
|
242
|
+
has_rdoc:
|