levelup 0.9.3 → 0.9.4

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: 238e90b50ace8d0dda415d36dcd75b7d0af2023f
4
- data.tar.gz: a6d9b1a494b008804eafece8a06e45a788c61dd3
3
+ metadata.gz: 37ecaa0b0077be335d54744b34de2883647a9e99
4
+ data.tar.gz: 1eb778f8427864d578c0aa16c52b67701ac9ec42
5
5
  SHA512:
6
- metadata.gz: 32ccd34e752ccdd08d5e474a68522bc16259dd4d50341f6550bbdcedc68196a00854bdc2a40928d71b1316073ad637830f3215fd6688e39fab33da17579a3006
7
- data.tar.gz: 4779600aa8094b8af4fca1a07d5580feffe665e5fa0b76f8b2a17c5821c36e78107de0219a31450bdf36654c7f34f1a07b2603d2c0bd3349291c8717044bcb34
6
+ metadata.gz: 46a0863b7ee1a7e091f658dfd855a41a75fbb19a45441e2d44abbce8a13dbaf0633832f4b20aedf49d50465e7027829d19862996db9d814661f9bd9277725c38
7
+ data.tar.gz: 82b2541958f7c3308ab338595d204234ea770976c3a6981362801142932bb62d0d85d9291344950b33856cd8946d2632231c6a5052e261d0d80823fa05a9f6c7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- levelup (0.9.3)
4
+ levelup (0.9.4)
5
5
  httparty (~> 0.13.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -66,8 +66,15 @@ response = api.orders.create(
66
66
  spend_amount: 350, # in cents; 350 = $3.50
67
67
  items: [
68
68
  {
69
- # item data
69
+ charged_price: 350,
70
+ description: 'Non-poisonous, supplies vital nutrients',
71
+ name: 'Food',
72
+ quantity: 1,
73
+ sku: '123abc',
74
+ category: 'Edible Things',
75
+ standard_price: 350
70
76
  }
77
+ # more items can go here
71
78
  ],
72
79
  merchant_access_token: 'merchant-token',
73
80
  user_access_token: 'user-token')
@@ -29,4 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'webmock', '~> 1.17.4'
30
30
 
31
31
  spec.add_runtime_dependency 'httparty', '~> 0.13.1'
32
+
33
+ spec.required_ruby_version = '>= 1.9.3'
32
34
  end
@@ -18,6 +18,7 @@ require 'levelup/requests/create_address'
18
18
  require 'levelup/requests/create_card'
19
19
  require 'levelup/requests/create_order'
20
20
  require 'levelup/requests/create_user'
21
+ require 'levelup/requests/get_location_credit'
21
22
  require 'levelup/requests/get_order'
22
23
  require 'levelup/requests/get_qr_code'
23
24
  require 'levelup/requests/get_user'
@@ -41,6 +42,7 @@ require 'levelup/endpoints/app_locations'
41
42
  require 'levelup/endpoints/app_users'
42
43
  require 'levelup/endpoints/apps'
43
44
  require 'levelup/endpoints/credit_cards'
45
+ require 'levelup/endpoints/location_credit'
44
46
  require 'levelup/endpoints/location_orders'
45
47
  require 'levelup/endpoints/merchant_funded_credits'
46
48
  require 'levelup/endpoints/merchant_locations'
@@ -15,10 +15,10 @@ module Levelup
15
15
 
16
16
  # Accepts any combination of the listed parameters, though +api_key+ and
17
17
  # +secret+ work in tandem.
18
- def initialize(app_access_token: nil, api_key: nil, secret: nil)
19
- self.app_access_token = app_access_token
20
- self.api_key = api_key
21
- self.secret = secret
18
+ def initialize(options = {})
19
+ self.app_access_token = options[:app_access_token]
20
+ self.api_key = options[:api_key]
21
+ self.secret = options[:secret]
22
22
  end
23
23
 
24
24
  # Generates an interface for the +access_tokens+ endpoint.
@@ -1,6 +1,6 @@
1
1
  module Levelup
2
2
  class Configuration
3
- VERSION = '0.9.3'
3
+ VERSION = '0.9.4'
4
4
  DEFAULT_API_VERSION = :v15
5
5
 
6
6
  class << self
@@ -8,9 +8,9 @@ module Levelup
8
8
  # The client secret assigned to your app. Preconfigured key.
9
9
  attr_writer :secret
10
10
 
11
- def initialize(api_key: nil, secret: nil)
12
- @api_key = api_key
13
- @secret = secret
11
+ def initialize(auth_info)
12
+ @api_key = auth_info[:api_key]
13
+ @secret = auth_info[:secret]
14
14
  end
15
15
 
16
16
  # Generates a new app access token. If passed no parameters, attempts to
@@ -3,11 +3,6 @@ module Levelup
3
3
  # The endpoint holding all functions related to managing users' credit
4
4
  # cards.
5
5
  class CreditCards < Base
6
- def initialize(api_key: nil, secret: nil)
7
- @api_key = api_key
8
- @secret = secret
9
- end
10
-
11
6
  # Adds a credit card to a user's account. Requires a user access token
12
7
  # with create_first_credit_card permission.
13
8
  # This request will fail unless the user account has no credit card on it.
@@ -0,0 +1,25 @@
1
+ module Levelup
2
+ module Endpoints
3
+ # The endpoint holding all functions relating to available credit at
4
+ # locations.
5
+ class LocationCredit < Base
6
+ attr_reader :id
7
+
8
+ def initialize(location_id)
9
+ @id = location_id
10
+ end
11
+
12
+ def get(user_access_token)
13
+ request =
14
+ Requests::GetLocationCredit.new(user_access_token: user_access_token)
15
+ request.send_to_api(:get, endpoint_path)
16
+ end
17
+
18
+ private
19
+
20
+ def path
21
+ "locations/#{id}/credit"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -2,10 +2,10 @@ module Levelup
2
2
  module Endpoints
3
3
  # The endpoint holding all functions related to managing users' QR codes.
4
4
  class QrCodes < Base
5
- def initialize(color: 0, tip_amount: 0, tip_percent: 0)
6
- self.color = color
7
- self.tip_amount = tip_amount
8
- self.tip_percent = tip_percent
5
+ def initialize(options = {})
6
+ self.color = options[:color] || 0
7
+ self.tip_amount = options[:tip_amount] || 0
8
+ self.tip_percent = options[:tip_percent] || 0
9
9
  end
10
10
 
11
11
  # Retrieves the specified user's QR code using parameters specified
@@ -14,6 +14,10 @@ module Levelup
14
14
  LocationOrders.new(id)
15
15
  end
16
16
 
17
+ def credit
18
+ LocationCredit.new(id)
19
+ end
20
+
17
21
  private
18
22
 
19
23
  def path
@@ -0,0 +1,13 @@
1
+ module Levelup
2
+ module Requests
3
+ # Represents a request to access information about a
4
+ # specific order under a merchant.
5
+ class GetLocationCredit < Base
6
+ include Templates::UserAuthenticated
7
+
8
+ def response_from_hash(hash)
9
+ Responses::Success.new(hash['credit'])
10
+ end
11
+ end
12
+ end
13
+ end
@@ -37,9 +37,9 @@ describe 'Levelup::Responses::Error' do
37
37
  it 'has two full errors' do
38
38
  expect(@nonempty_response).to have(2).errors
39
39
  @nonempty_response.errors.each do |error|
40
- expect(error['property']).to_not be_nil
41
- expect(error['object']).to_not be_nil
42
- expect(error['message']).to_not be_nil
40
+ expect(error.property).to_not be_nil
41
+ expect(error.object).to_not be_nil
42
+ expect(error.message).to_not be_nil
43
43
  end
44
44
  end
45
45
  end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Levelup::Endpoints::LocationCredit', vcr: true do
4
+ describe '#get' do
5
+ context 'with a valid user token' do
6
+ it 'returns a credit value at a location' do
7
+ response = @test_client.locations(TestConfig.location_id).credit.
8
+ get(TestConfig.user_token_with_manage_campaigns_perms)
9
+ expect(response).to be_success
10
+ expect(response.total_amount).to_not be_nil
11
+ end
12
+ end
13
+
14
+ context 'with an invalid user token' do
15
+ it 'returns an error response' do
16
+ response = @test_client.locations(TestConfig.location_id).credit.
17
+ get('1234')
18
+ expect(response).to_not be_success
19
+ end
20
+ end
21
+ end
22
+ end
@@ -13,4 +13,5 @@ user_token_with_manage_addresses_perms: token (can be same as other user token)
13
13
  user_token_with_read_info_perms: token (can be same as other user token)
14
14
  user_token_with_read_orders_perms: token (can be same as other user token)
15
15
  user_token_with_read_qr_perms: token (can be same as other user token)
16
+ user_token_with_manage_campaigns_perms: token (can be same as other user token)
16
17
  user_email: user@email.tld
@@ -5,7 +5,7 @@ require 'support/vcr_filter_sensitive_data'
5
5
  $LOAD_PATH << File.expand_path('../lib', __FILE__)
6
6
  require 'levelup'
7
7
 
8
- Levelup::Configuration.base_api_url = 'https://api.staging-levelup.com/'
8
+ Levelup::Configuration.base_api_url = 'https://sandbox.thelevelup.com/'
9
9
 
10
10
  class TestConfig < Settingslogic
11
11
  source 'spec/fixtures/keys.yml'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: levelup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - LevelUp POS Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-26 00:00:00.000000000 Z
11
+ date: 2014-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -163,6 +163,7 @@ files:
163
163
  - lib/levelup/endpoints/apps.rb
164
164
  - lib/levelup/endpoints/base.rb
165
165
  - lib/levelup/endpoints/credit_cards.rb
166
+ - lib/levelup/endpoints/location_credit.rb
166
167
  - lib/levelup/endpoints/location_orders.rb
167
168
  - lib/levelup/endpoints/merchant_funded_credits.rb
168
169
  - lib/levelup/endpoints/merchant_locations.rb
@@ -187,6 +188,7 @@ files:
187
188
  - lib/levelup/requests/create_card.rb
188
189
  - lib/levelup/requests/create_order.rb
189
190
  - lib/levelup/requests/create_user.rb
191
+ - lib/levelup/requests/get_location_credit.rb
190
192
  - lib/levelup/requests/get_order.rb
191
193
  - lib/levelup/requests/get_qr_code.rb
192
194
  - lib/levelup/requests/get_user.rb
@@ -222,6 +224,7 @@ files:
222
224
  - spec/endpoints/access_tokens_spec.rb
223
225
  - spec/endpoints/app_locations_spec.rb
224
226
  - spec/endpoints/app_users_spec.rb
227
+ - spec/endpoints/location_credit_spec.rb
225
228
  - spec/endpoints/location_orders_spec.rb
226
229
  - spec/endpoints/merchant_funded_credits_spec.rb
227
230
  - spec/endpoints/merchant_locations_spec.rb
@@ -247,7 +250,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
247
250
  requirements:
248
251
  - - ">="
249
252
  - !ruby/object:Gem::Version
250
- version: '0'
253
+ version: 1.9.3
251
254
  required_rubygems_version: !ruby/object:Gem::Requirement
252
255
  requirements:
253
256
  - - ">="
@@ -274,6 +277,7 @@ test_files:
274
277
  - spec/endpoints/access_tokens_spec.rb
275
278
  - spec/endpoints/app_locations_spec.rb
276
279
  - spec/endpoints/app_users_spec.rb
280
+ - spec/endpoints/location_credit_spec.rb
277
281
  - spec/endpoints/location_orders_spec.rb
278
282
  - spec/endpoints/merchant_funded_credits_spec.rb
279
283
  - spec/endpoints/merchant_locations_spec.rb