passworks 2.0.6 → 2.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f0480105b8f657cf34ba5a0bff97cd120346d8a
4
- data.tar.gz: eeeb917929097fe0845dcbe611b1d9e5dcc51dc5
3
+ metadata.gz: e990ab5970bb68b77a21d59e1e6e63513073eaee
4
+ data.tar.gz: 375fe8d42894e3c41941bddac0e707dd0e0abd15
5
5
  SHA512:
6
- metadata.gz: 4b4afb455a3e6ed3f6c18b8e68c80d22a17c361fbde804eef944101a3b378a89bd464104c745cd238cfecd4bcb1a5da233871a48070892f2f896f19941c1c282
7
- data.tar.gz: 9e3a857b0f74db7128e96b41179e7921b28a863516793201a8d4a821d48a0f03c54d57fd6a61a8c45056ade11428e7ef84bcbccec960cf971ea6f253a18b67b1
6
+ metadata.gz: a9923c4fabc5803658f5ed5c23bc5291df058c28d45fbead858b2eefe452b6aff3abae4e290e54e2187e335d739a88e80caae7279eb2cf2808e151d1ef80bf5c
7
+ data.tar.gz: 55a25f5293701cc0133af284325563bf9b413834d22a7e2ca68a83bb526bea95d3d378f4f32a124073295617a62eb0b6ac5ce6293c9836c49473c829913721ad
@@ -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
 
@@ -17,6 +17,7 @@ require 'passworks/resource'
17
17
  require 'passworks/campaign_resource'
18
18
  require 'passworks/asset_resource'
19
19
  require 'passworks/certificate_resource'
20
+ require 'passworks/template_resource'
20
21
  require 'passworks/pass_resource'
21
22
 
22
23
  # Passworks
@@ -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
@@ -0,0 +1,8 @@
1
+ require 'passworks/exception'
2
+
3
+ module Passworks
4
+ module Exceptions
5
+ class InvalidUUID < Exception
6
+ end
7
+ end
8
+ end
@@ -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
- else
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
 
@@ -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, :delete
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
@@ -1,3 +1,3 @@
1
1
  module Passworks
2
- VERSION = "2.0.6"
2
+ VERSION = "2.0.7"
3
3
  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: 2.0.6
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: 2015-12-23 00:00:00.000000000 Z
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