gifter_hub 0.1.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7defb41a5e8993cf87b5267687a41aee0e9dc49
4
- data.tar.gz: fa4afb84cfbd7644a8d47c61dc49ec2e73aa630c
3
+ metadata.gz: 4ca2b5ca79d45d5fe435e9881d3e61455e37dfa2
4
+ data.tar.gz: ea8159d053556f2efeeac4f18b1f8d74e9a5f9d5
5
5
  SHA512:
6
- metadata.gz: 510d7152ffb95850da530658f126bbd14dc4cf1187c802137c02d9dd6966f529a184445840a72c307cbefd6b8c6e337acafdeb044d9b7218bd673dd7c16f8e6c
7
- data.tar.gz: 11dcb9cf1a4004febf2d7ebfb437760c5cffc01e2087f20cf6e0d1db2c8b0320e32e88a8eb48293be3b230479fd9da4ba39da8333b4b56d027a3ab46ed588f19
6
+ metadata.gz: b4c9f100d64c19f7ca7a50aff27ef3d886276e98b840603b22eb6368b769f367a8a50331f8f44bd4dca065a823d5fd4c56e3d9adc060537c6d90c341d795c4fc
7
+ data.tar.gz: 2f15e10f5d09134dd70e5f8c0c20af1aff1377b3747a1354f12374a84387434e72d625095a439eaa83b7e1c5bd64eb93db93e6a4fad62a0f1fa7a085017c2798
@@ -1,12 +1,13 @@
1
1
  module GifterHub
2
2
  class ApiResource
3
3
  include Operations::Get
4
- attr_accessor :id, :opts
4
+ attr_accessor :id, :opts, :attributes
5
5
 
6
6
  def initialize(id=nil, opts={})
7
7
  @id = id
8
8
  @opts = opts
9
9
  @values = {}
10
+ @attributes = {}
10
11
  end
11
12
 
12
13
  def self.class_name
@@ -17,12 +18,17 @@ module GifterHub
17
18
  if self == ApiResource
18
19
  raise NotImplementedError
19
20
  end
20
- "/api#{CGI.escape(class_name.tableize)}"
21
+ "/api/#{CGI.escape(class_name.tableize)}"
21
22
  end
22
23
 
23
24
  def self.get(id, opts={})
24
25
  instance = self.new(id, opts)
25
26
  instance.refresh
27
+ instance
28
+ end
29
+
30
+ def inspect
31
+ JSON.pretty_generate(attributes)
26
32
  end
27
33
 
28
34
  def resource_url
@@ -36,30 +42,18 @@ module GifterHub
36
42
 
37
43
  private
38
44
 
39
- def self.check_id!(id)
40
- raise TypeError.new('id should be a string') unless id.is_a? String
41
- id
42
- end
43
-
44
- def protected_fields
45
- []
46
- end
47
-
48
45
  # Convert hash key value pair to method
49
46
  def initialize_from(values, opts={})
50
47
  @opts = opts
51
48
  added = Set.new(values.keys - @values.keys)
52
- instance_eval do
53
- add_accessors(added, values)
54
- end
49
+ @attributes = values
50
+ add_accessors(added, values)
55
51
  self
56
52
  end
57
53
 
58
54
  def add_accessors(keys, values)
59
- f = protected_fields
60
55
  metaclass.instance_eval do
61
56
  keys.each do |k|
62
- next if f.include?(k)
63
57
  define_method(k) { values[k] }
64
58
 
65
59
  if [FalseClass, TrueClass].include?(values[k].class)
@@ -1,6 +1,6 @@
1
1
  module GifterHub
2
2
  module Errors
3
- class ApiConnectionError < BambooError
3
+ class ApiConnectionError < GifterHubError
4
4
  end
5
5
  end
6
6
  end
@@ -1,6 +1,6 @@
1
1
  module GifterHub
2
2
  module Errors
3
- class ApiError < BambooError
3
+ class ApiError < GifterHubError
4
4
  end
5
5
  end
6
6
  end
@@ -1,6 +1,6 @@
1
1
  module GifterHub
2
2
  module Errors
3
- class BambooError < StandardError
3
+ class GifterHubError < StandardError
4
4
  attr_reader :message
5
5
  attr_reader :http_status
6
6
  attr_reader :http_body
@@ -1,7 +1,5 @@
1
1
  module GifterHub
2
2
  class GiftCard < ApiResource
3
- extend Operations::Create
4
-
5
3
  def redeem(params)
6
4
  response = request(:post, redeem_url, params)
7
5
  initialize_from(response)
@@ -1,3 +1,3 @@
1
1
  module GifterHub
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gifter_hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Devhub
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-13 00:00:00.000000000 Z
11
+ date: 2018-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,7 +94,7 @@ files:
94
94
  - lib/gifter_hub/api_resource.rb
95
95
  - lib/gifter_hub/errors/api_connection_error.rb
96
96
  - lib/gifter_hub/errors/api_error.rb
97
- - lib/gifter_hub/errors/bamboo_error.rb
97
+ - lib/gifter_hub/errors/gifter_hub_error.rb
98
98
  - lib/gifter_hub/gift_card.rb
99
99
  - lib/gifter_hub/operations/create.rb
100
100
  - lib/gifter_hub/operations/get.rb