passworks 2.0.6 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/passworks.rb +1 -0
- data/lib/passworks/client.rb +1 -1
- data/lib/passworks/exceptions/invalid_uuid.rb +8 -0
- data/lib/passworks/inflector.rb +6 -1
- data/lib/passworks/request.rb +2 -2
- data/lib/passworks/request_proxy.rb +4 -2
- data/lib/passworks/template_resource.rb +19 -0
- data/lib/passworks/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e990ab5970bb68b77a21d59e1e6e63513073eaee
|
4
|
+
data.tar.gz: 375fe8d42894e3c41941bddac0e707dd0e0abd15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9923c4fabc5803658f5ed5c23bc5291df058c28d45fbead858b2eefe452b6aff3abae4e290e54e2187e335d739a88e80caae7279eb2cf2808e151d1ef80bf5c
|
7
|
+
data.tar.gz: 55a25f5293701cc0133af284325563bf9b413834d22a7e2ca68a83bb526bea95d3d378f4f32a124073295617a62eb0b6ac5ce6293c9836c49473c829913721ad
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,9 @@
|
|
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
|
+
## v2.0.7 (2016-01-05)
|
7
|
+
* Now able to delete assets and templates.
|
8
|
+
|
6
9
|
## v2.0.6 (2015-12-22)
|
7
10
|
* Fixed JSON errors when displaying attributes with a single error (non-array-format).
|
8
11
|
|
data/lib/passworks.rb
CHANGED
data/lib/passworks/client.rb
CHANGED
@@ -35,7 +35,7 @@ module Passworks
|
|
35
35
|
# @!method generics
|
36
36
|
# Allows to to access the Generic API
|
37
37
|
# @return [Passworks::RequestProxy]
|
38
|
-
%w(certificates assets boarding_passes store_cards coupons event_tickets generics).each do |collection_name|
|
38
|
+
%w(certificates assets templates boarding_passes store_cards coupons event_tickets generics).each do |collection_name|
|
39
39
|
define_method(collection_name) do
|
40
40
|
Passworks::RequestProxy.new(self, collection_name, nil)
|
41
41
|
end
|
data/lib/passworks/inflector.rb
CHANGED
@@ -9,6 +9,8 @@ module Passworks
|
|
9
9
|
'asset'
|
10
10
|
when 'certificates'
|
11
11
|
'certificate'
|
12
|
+
when 'templates'
|
13
|
+
'template'
|
12
14
|
when 'boarding_passes'
|
13
15
|
'boarding_pass'
|
14
16
|
when 'coupons'
|
@@ -31,10 +33,13 @@ module Passworks
|
|
31
33
|
return Passworks::AssetResource if collection_name == 'assets'
|
32
34
|
# CertificateResource has no overrides, but follow along the normal flow.
|
33
35
|
return Passworks::CertificateResource if collection_name == 'certificates'
|
36
|
+
return Passworks::TemplateResource if collection_name == 'templates'
|
34
37
|
if collection_uuid
|
35
38
|
Passworks::PassResource
|
36
|
-
|
39
|
+
elsif ['boarding_passes', 'coupons', 'store_cards', 'event_tickets', 'generics'].include?(collection_name)
|
37
40
|
Passworks::CampaignResource
|
41
|
+
else
|
42
|
+
raise 'Invalid Resource Class'
|
38
43
|
end
|
39
44
|
end
|
40
45
|
|
data/lib/passworks/request.rb
CHANGED
@@ -4,9 +4,9 @@ module Passworks
|
|
4
4
|
def request(method, path, options={})
|
5
5
|
response = agent.send(method) do |request|
|
6
6
|
case method
|
7
|
-
when :get
|
7
|
+
when :get
|
8
8
|
request.url(path, options[:query])
|
9
|
-
when :post, :put, :patch
|
9
|
+
when :post, :put, :patch, :delete
|
10
10
|
request.path = path
|
11
11
|
request.body = options.fetch(:body, {})
|
12
12
|
end
|
@@ -14,7 +14,7 @@ module Passworks
|
|
14
14
|
# @return [String] Collection UUID
|
15
15
|
attr_reader :collection_uuid
|
16
16
|
|
17
|
-
def initialize(client, collection_name, collection_uuid=nil, options={})
|
17
|
+
def initialize(client, collection_name, collection_uuid = nil, options = {})
|
18
18
|
@collection_name = collection_name
|
19
19
|
@collection_uuid = collection_uuid
|
20
20
|
@client = client
|
@@ -30,7 +30,7 @@ module Passworks
|
|
30
30
|
# @example Fetching the very first coupon pass from the first coupon (campaign) without having to pull all the elements first from the server
|
31
31
|
# client.coupons.all(per_page: 1).first.passes.all(per_page: 1).first
|
32
32
|
# @return [Passworks::CollectionProxy]
|
33
|
-
def all(options={})
|
33
|
+
def all(options = {})
|
34
34
|
options = { query: options } unless options.empty?
|
35
35
|
CollectionProxy.new(client, collection_name, collection_uuid, options)
|
36
36
|
end
|
@@ -44,6 +44,8 @@ module Passworks
|
|
44
44
|
# pass = client.coupons.all(per_page: 1).first.passes.find('c3d5fc64-3a43-4d3a-a167-473dfeb1edd3')
|
45
45
|
# @return [PassResource.new or CampaignResource]
|
46
46
|
def find(uuid)
|
47
|
+
# TODO @tparreira add a validation for UUID.
|
48
|
+
raise Passworks::Exceptions::InvalidUUID.new("The UUID supplied is invalid.") if uuid.empty?
|
47
49
|
if collection_uuid
|
48
50
|
fetch_url = "#{collection_name}/#{collection_uuid}/passes/#{uuid}"
|
49
51
|
else
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Passworks
|
2
|
+
class TemplateResource < Resource
|
3
|
+
|
4
|
+
# Deletes the current Template
|
5
|
+
# @return [Boolean]
|
6
|
+
def delete(delete_assets = true)
|
7
|
+
content = {
|
8
|
+
body: {
|
9
|
+
single_name.to_sym => {
|
10
|
+
delete_assets: delete_assets
|
11
|
+
}
|
12
|
+
}
|
13
|
+
}
|
14
|
+
response = client.delete("#{collection_name}/#{id}", content)
|
15
|
+
end
|
16
|
+
alias_method :destroy, :delete
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/passworks/version.rb
CHANGED
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: 2.0.
|
4
|
+
version: 2.0.7
|
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: 2016-01-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- lib/passworks/exceptions/forbidden.rb
|
183
183
|
- lib/passworks/exceptions/gateway_timeout.rb
|
184
184
|
- lib/passworks/exceptions/internal_server_error.rb
|
185
|
+
- lib/passworks/exceptions/invalid_uuid.rb
|
185
186
|
- lib/passworks/exceptions/method_not_allowed.rb
|
186
187
|
- lib/passworks/exceptions/not_found.rb
|
187
188
|
- lib/passworks/exceptions/not_implemented.rb
|
@@ -197,6 +198,7 @@ files:
|
|
197
198
|
- lib/passworks/request_proxy.rb
|
198
199
|
- lib/passworks/resource.rb
|
199
200
|
- lib/passworks/response.rb
|
201
|
+
- lib/passworks/template_resource.rb
|
200
202
|
- lib/passworks/version.rb
|
201
203
|
- passworks.gemspec
|
202
204
|
- spec/.DS_Store
|