perka 1.4 → 1.5

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.
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
  require 'rake/testtask'
3
3
 
4
- API_SRC = "https://getperka.com/api/2/describe"
4
+ API_SRC = "https://sandbox.getperka.com/api/2/describe"
5
5
  SRC_DIR = "#{File.dirname(__FILE__)}/src"
6
6
  OUTPUT_DIR = "#{File.dirname(__FILE__)}/target"
7
7
  FLATPACK_OUTPUT_DIR = "#{OUTPUT_DIR}/generated"
@@ -11,22 +11,30 @@ module Perka
11
11
  to_return
12
12
  end
13
13
 
14
- # Returns the current customer's PointsActivity status across all merchants
14
+ # Retrieves the customer associated with the given uuid. The response will include
15
+ # reward and tierTraversal information for the merchant associated with the
16
+ # logged in clerk or merchantUser.
17
+ def customer_uuid_get(uuid)
18
+ to_return = Flatpack::Client::FlatpackRequest.new(self, "GET", "/api/2/customer/{uuid}", uuid)
19
+ to_return
20
+ end
21
+
22
+ # Returns the current customer's PointsActivity status across all merchants
15
23
  # with a points-based loyalty system.
16
24
  def customer_points_get
17
25
  to_return = Flatpack::Client::FlatpackRequest.new(self, "GET", "/api/2/customer/points")
18
26
  to_return
19
27
  end
20
28
 
21
- # Performs a deep serialization of an entity. This endpoint is intended to provide
22
- # supplementary one-to-many relationship data that is not normally serialized
29
+ # Performs a deep serialization of an entity. This endpoint is intended to provide
30
+ # supplementary one-to-many relationship data that is not normally serialized
23
31
  # to keep payload sizes manageable.
24
32
  def describe_type_uuid_get(type, uuid)
25
33
  to_return = DescribeTypeUuidGet.new(self, type, uuid)
26
34
  to_return
27
35
  end
28
36
 
29
- # Provides a machine-readable description of an entity type per the logged-in
37
+ # Provides a machine-readable description of an entity type per the logged-in
30
38
  # role.
31
39
  def describe_type_get(type)
32
40
  to_return = Flatpack::Client::FlatpackRequest.new(self, "GET", "/api/2/describe/{type}", type)
@@ -39,7 +47,7 @@ module Perka
39
47
  to_return
40
48
  end
41
49
 
42
- # A diagnostic endpoint to extract the information from an OAuth2 authorization
50
+ # A diagnostic endpoint to extract the information from an OAuth2 authorization
43
51
  # code, login token, session token, or refresh token.
44
52
  def describe_token_get
45
53
  to_return = DescribeTokenGet.new(self)
@@ -52,9 +60,9 @@ module Perka
52
60
  to_return
53
61
  end
54
62
 
55
- # Add or replace an annotation applied to a persistent entity. If the value
56
- # of <entityReference payloadName='entityAnnotation'> EntityAnnotation</entityReference>
57
- # is missing or <code>null</code>, the annotation will be removed. This method
63
+ # Add or replace an annotation applied to a persistent entity. If the value
64
+ # of <entityReference payloadName='entityAnnotation'> EntityAnnotation</entityReference>
65
+ # is missing or <code>null</code>, the annotation will be removed. This method
58
66
  # will return the previously-stored annotation, if any.
59
67
  def annotation_put(entity)
60
68
  to_return = Flatpack::Client::FlatpackRequest.new(self, "PUT", "/api/2/annotation")
@@ -62,20 +70,20 @@ module Perka
62
70
  to_return
63
71
  end
64
72
 
65
- # Creates a new customer associated with the current <entityReference payloadName='integratorUser'>
66
- # IntegratorUser</entityReference>, or returns an existing customer if a matching
67
- # customer already exists. The given <entityReference payloadName='userCredentials'>
68
- # UserCredentials</entityReference> must include an email, phone, or both. The
69
- # following rules will be used to determine if a new customer should be created
70
- # <ul> <li>If a customer exists with a matching <b>confirmed</b> email address
71
- # or <b>confirmed</b> phone number, that customer will be returned.</li> <li>If
72
- # a customer exists that is associated with the current <entityReference payloadName='integratorUser'>
73
- # IntegratorUser</entityReference>, and has a matching <b>unconfirmed</b> email
74
- # address or <b>unconfirmed</b> phone number, that customer will be returned.
75
- # The email check will happen first, and will short-circuit the phone check
76
- # if a match is found.</li> <li>Otherwise, a new customer will be created and
77
- # associated with your <entityReference payloadName='integratorUser'> IntegratorUser</entityReference>.
78
- # The given phone number and email address will be stored as unconfirmed values.
73
+ # Creates a new customer associated with the current <entityReference payloadName='integratorUser'>
74
+ # IntegratorUser</entityReference>, or returns an existing customer if a matching
75
+ # customer already exists. The given <entityReference payloadName='userCredentials'>
76
+ # UserCredentials</entityReference> must include an email, phone, or both. The
77
+ # following rules will be used to determine if a new customer should be created
78
+ # <ul> <li>If a customer exists with a matching <b>confirmed</b> email address
79
+ # or <b>confirmed</b> phone number, that customer will be returned.</li> <li>If
80
+ # a customer exists that is associated with the current <entityReference payloadName='integratorUser'>
81
+ # IntegratorUser</entityReference>, and has a matching <b>unconfirmed</b> email
82
+ # address or <b>unconfirmed</b> phone number, that customer will be returned.
83
+ # The email check will happen first, and will short-circuit the phone check
84
+ # if a match is found.</li> <li>Otherwise, a new customer will be created and
85
+ # associated with your <entityReference payloadName='integratorUser'> IntegratorUser</entityReference>.
86
+ # The given phone number and email address will be stored as unconfirmed values.
79
87
  # </ul>
80
88
  def integrator_customer_post(entity)
81
89
  to_return = Flatpack::Client::FlatpackRequest.new(self, "POST", "/api/2/integrator/customer")
@@ -89,7 +97,7 @@ module Perka
89
97
  to_return
90
98
  end
91
99
 
92
- # Completely destroys all customer data associated with the current integrator
100
+ # Completely destroys all customer data associated with the current integrator
93
101
  # user. This endpoint is only available in the sandbox environment.
94
102
  def integrator_destroy_delete
95
103
  to_return = Flatpack::Client::FlatpackRequest.new(self, "DELETE", "/api/2/integrator/destroy")
@@ -108,7 +116,7 @@ module Perka
108
116
  to_return
109
117
  end
110
118
 
111
- # Updates an existing <entityReference payloadName='customer'> Customer</entityReference>
119
+ # Updates an existing <entityReference payloadName='customer'> Customer</entityReference>
112
120
  # manageed by the current <entityReference payloadName='integratorUser'> IntegratorUser</entityReference>.
113
121
  def integrator_customer_put(entity)
114
122
  to_return = Flatpack::Client::FlatpackRequest.new(self, "PUT", "/api/2/integrator/customer")
@@ -116,33 +124,28 @@ module Perka
116
124
  to_return
117
125
  end
118
126
 
119
- # Returns a sparse payload of all live <entityReference payloadName='merchantLocation'>
120
- # locations</entityReference> and their associated <entityReference payloadName='merchant'>
127
+ # Returns a sparse payload of all live <entityReference payloadName='merchantLocation'>
128
+ # locations</entityReference> and their associated <entityReference payloadName='merchant'>
121
129
  # merchants</entityReference>.
122
130
  def merchant_locations_get
123
131
  to_return = Flatpack::Client::FlatpackRequest.new(self, "GET", "/api/2/merchant/locations")
124
132
  to_return
125
133
  end
126
134
 
127
- # Allows a <entityReference payloadName='customer'> Customer's</entityReference>
128
- # reward status to be retrieved. Customers may be searched for by UUID.
129
- def customer_reward_get
130
- to_return = CustomerRewardGet.new(self)
131
- to_return
132
- end
133
-
134
- # Reward a Customer. This method will implicitly create a <entityReference payloadName='visit'>
135
- # Visit</entityReference> which will be returned.
135
+ # Rewards a Customer. This method will implicitly create a <entityReference
136
+ # payloadName='visit'> Visit</entityReference> which will be returned. The response
137
+ # will also include any s manipulated by this visit, as well as the customer's
138
+ # most recent @{link TierTraversal} at the associated @{link Merchant}
136
139
  def customer_reward_put(entity)
137
140
  to_return = Flatpack::Client::FlatpackRequest.new(self, "PUT", "/api/2/customer/reward")
138
141
  to_return.entity = entity
139
142
  to_return
140
143
  end
141
144
 
142
- # Rewrites the history of a customer's latest validated visit to a merchant.
143
- # The <entityReference payloadName='abstractRewardConfirmation'> AbstractRewardConfirmation</entityReference>
144
- # instances associated with the <entityReference payloadName='visitConfirmation'>
145
- # VisitConfirmation</entityReference> should reflect the desired state of the
145
+ # Rewrites the history of a customer's latest validated visit to a merchant.
146
+ # The <entityReference payloadName='abstractRewardConfirmation'> AbstractRewardConfirmation</entityReference>
147
+ # instances associated with the <entityReference payloadName='visitConfirmation'>
148
+ # VisitConfirmation</entityReference> should reflect the desired state of the
146
149
  # Visit. <p> This method will return the updated Visit.
147
150
  def customer_visit_amend_put(entity)
148
151
  to_return = Flatpack::Client::FlatpackRequest.new(self, "PUT", "/api/2/customer/visit/amend")
@@ -150,9 +153,9 @@ module Perka
150
153
  to_return
151
154
  end
152
155
 
153
- # Creates a new outstanding visit for the current customer at the given location.
154
- # If the customer has no active Rewards at the associated merchant, a new Reward
155
- # will be created for each of the merchant's programs. Information about the
156
+ # Creates a new outstanding visit for the current customer at the given location.
157
+ # If the customer has no active Rewards at the associated merchant, a new Reward
158
+ # will be created for each of the merchant's programs. Information about the
156
159
  # visit, and all active rewards for the associated merchant will be returned.
157
160
  def customer_visit_post(entity)
158
161
  to_return = Flatpack::Client::FlatpackRequest.new(self, "POST", "/api/2/customer/visit")
@@ -160,17 +163,17 @@ module Perka
160
163
  to_return
161
164
  end
162
165
 
163
- # Returns a sparse list of visits at the current merchant location that are
164
- # un-validated, or that occurred after the time of the most recent validated
165
- # visit given. This request must be made with a anonymous clerk role that corresponds
166
+ # Returns a sparse list of visits at the current merchant location that are
167
+ # un-validated, or that occurred after the time of the most recent validated
168
+ # visit given. This request must be made with a anonymous clerk role that corresponds
166
169
  # to exactly one MerchantLocation.
167
170
  def customer_visit_get
168
171
  to_return = CustomerVisitGet.new(self)
169
172
  to_return
170
173
  end
171
174
 
172
- # Checks for the validation of an outstanding visit and returns a sparse payload
173
- # of <entityReference payloadName='visit'> Visit</entityReference> and related
175
+ # Checks for the validation of an outstanding visit and returns a sparse payload
176
+ # of <entityReference payloadName='visit'> Visit</entityReference> and related
174
177
  # items.
175
178
  def customer_visit_validate_get
176
179
  to_return = CustomerVisitValidateGet.new(self)
@@ -192,8 +195,8 @@ module Perka
192
195
  super(api, "GET", "/api/2/describe/{type}/{uuid}", *args)
193
196
  end
194
197
 
195
- # An ISO8601-formatted datetime that will be used to filter the entities in
196
- # the payload's data section to those that were created or updated after the
198
+ # An ISO8601-formatted datetime that will be used to filter the entities in
199
+ # the payload's data section to those that were created or updated after the
197
200
  # specified time
198
201
  def with_last_modified(last_modified)
199
202
  query_parameter('lastModified', last_modified);
@@ -213,29 +216,16 @@ module Perka
213
216
 
214
217
  end
215
218
 
216
- class CustomerRewardGet < Flatpack::Client::FlatpackRequest
217
-
218
- def initialize(api, *args)
219
- super(api, "GET", "/api/2/customer/reward", *args)
220
- end
221
-
222
- # A UUID allocated by the server
223
- def with_customer_uuid(customer_uuid)
224
- query_parameter('customerUuid', customer_uuid);
225
- end
226
-
227
- end
228
-
229
219
  class CustomerVisitGet < Flatpack::Client::FlatpackRequest
230
220
 
231
221
  def initialize(api, *args)
232
222
  super(api, "GET", "/api/2/customer/visit", *args)
233
223
  end
234
224
 
235
- # By default, requests to this endpoint will hang for a period of time before
236
- # returning in order to wait for a visit associated with the location to be
237
- # created or updated. Setting this query parameter to <code>true</code> will
238
- # disable the hanging get behavior, which is appropriate for requests used
225
+ # By default, requests to this endpoint will hang for a period of time before
226
+ # returning in order to wait for a visit associated with the location to be
227
+ # created or updated. Setting this query parameter to <code>true</code> will
228
+ # disable the hanging get behavior, which is appropriate for requests used
239
229
  # for first-time UI initialization.
240
230
  def with_fast_poll(fast_poll)
241
231
  query_parameter('fastPoll', fast_poll);
@@ -3,48 +3,49 @@
3
3
  require 'perka/model/base_entity_global'
4
4
 
5
5
  module Perka
6
- module Model
6
+ module Model
7
7
 
8
8
  # Represents a specific offer extended to a merchant's customer base.
9
9
  class Coupon < BaseEntityGlobal
10
10
 
11
11
  PROPERTY_NAMES = [
12
- :summary,
13
- :redemption_limit,
14
-
15
- # The CouponVisibilites that control where and to whom the Coupon is available.
16
- :coupon_visibilities,
17
-
18
- # The parent CouponCampaign that aggregates related Coupons.
19
- :coupon_campaign,
20
-
21
- # The short perk icon name (e.g. <code>unicorn</code>).
22
- :image_name,
23
-
24
- # This property doesn't represent a single instance in time (i.e. a number
25
- # of milliseconds past the epoch in UTC time). Instead, this value must
26
- # be interpreted using the user's local timezone. For example, if the exact
27
- # instant stored in this value is noon UTC time on such-and-such a day,
28
- # this value should be interpreted to mean noon on that same date in the
29
- # user's local timezone.
30
- :local_begins_at,
31
-
32
- # See note on #getLocalBeginsAt() on how to interpret this.
33
- :local_ends_at,
34
- :notify_minutes_before,
35
- :perk_id,
36
- :url,
37
-
38
- # Indicates whether or not the Coupon will be actively pushed to customer
39
- # devices, or if it is a passive coupon.
40
- :push_enabled,
41
- :title
12
+ :summary,
13
+ :redemption_limit,
14
+
15
+ # The CouponVisibilites that control where and to whom the Coupon is available.
16
+ :coupon_visibilities,
17
+
18
+ # This property doesn't represent a single instance in time (i.e. a number
19
+ # of milliseconds past the epoch in UTC time). Instead, this value must
20
+ # be interpreted using the user's local timezone. For example, if the exact
21
+ # instant stored in this value is noon UTC time on such-and-such a day,
22
+ # this value should be interpreted to mean noon on that same date in the
23
+ # user's local timezone.
24
+ :local_begins_at,
25
+
26
+ # The parent CouponCampaign that aggregates related Coupons.
27
+ :coupon_campaign,
28
+
29
+ # See note on #getLocalBeginsAt() on how to interpret this.
30
+ :local_ends_at,
31
+
32
+ # The short perk icon name (e.g. <code>unicorn</code>).
33
+ :image_name,
34
+ :notify_minutes_before,
35
+ :perk_id,
36
+ :url,
37
+
38
+ # Indicates whether or not the Coupon will be actively pushed to customer
39
+ # devices, or if it is a passive coupon.
40
+ :push_enabled,
41
+ :title
42
42
  ]
43
43
  attr_accessor *PROPERTY_NAMES
44
44
 
45
+
45
46
  require 'perka/model/coupon_campaign'
46
47
  TYPE_MAP = {
47
- :coupon_campaign => Perka::Model::CouponCampaign
48
+ :coupon_campaign => Perka::Model::CouponCampaign
48
49
  }
49
50
 
50
51
  end
@@ -3,40 +3,42 @@
3
3
  require 'perka/model/base_entity_global'
4
4
 
5
5
  module Perka
6
- module Model
6
+ module Model
7
7
 
8
8
  # Merchants operate the retail locations that offer a Perka loyalty program.
9
9
  class Merchant < BaseEntityGlobal
10
10
 
11
11
  PROPERTY_NAMES = [
12
- :last_action_at,
13
- :program_tiers,
14
- :visit_expiration_minutes,
15
- :merchant_locations,
16
- :loyalty_type,
17
-
18
- # A list of Clerks, which are limited to acting on specific locations.
19
- :clerks,
20
- :merchant_state,
21
- :headline,
22
- :merchant_capabilities,
23
- :merchant_users,
24
- :notes,
25
-
26
- # Points-based merchants will define one or more catalog items for which
27
- # points can be redeemed.
28
- :points_catalog_items,
29
-
30
- # Points-based merchants may offer a signup bonus to new customers for signing
31
- # up.
32
- :points_signup_bonus,
33
- :terms,
34
- :sales_demo,
35
- :name
12
+ :last_action_at,
13
+ :visit_expiration_minutes,
14
+ :program_tiers,
15
+ :merchant_locations,
16
+ :loyalty_type,
17
+
18
+ # A list of Clerks, which are limited to acting on specific locations.
19
+ :clerks,
20
+ :merchant_state,
21
+ :sales_demo,
22
+ :headline,
23
+ :merchant_capabilities,
24
+ :merchant_users,
25
+ :notes,
26
+
27
+ # Points-based merchants will define one or more catalog items for which
28
+ # points can be redeemed.
29
+ :points_catalog_items,
30
+
31
+ # Points-based merchants may offer a signup bonus to new customers for signing
32
+ # up.
33
+ :points_signup_bonus,
34
+ :terms,
35
+ :website_url,
36
+ :name
36
37
  ]
37
38
  attr_accessor *PROPERTY_NAMES
38
39
 
39
40
 
41
+
40
42
  end
41
43
  end
42
44
  end
@@ -3,31 +3,32 @@
3
3
  require 'perka/model/base_entity_global'
4
4
 
5
5
  module Perka
6
- module Model
6
+ module Model
7
7
 
8
- # Program is a basic buy n(punchesNeeded) of x(purchasedItem), and get a free
8
+ # Program is a basic buy n(punchesNeeded) of x(purchasedItem), and get a free
9
9
  # y(freeItem) when a customer has reached a certain ProgramTier.
10
10
  class Program < BaseEntityGlobal
11
11
 
12
12
  PROPERTY_NAMES = [
13
- :program_tier,
14
- :program_type,
15
- :free_item,
16
- :punches_needed,
17
- :image_name,
18
- :perk_id,
19
- :terms,
20
- :punches_needed_prefix,
21
- :punches_needed_suffix,
22
- :purchased_item
13
+ :program_tier,
14
+ :program_type,
15
+ :free_item,
16
+ :punches_needed,
17
+ :image_name,
18
+ :perk_id,
19
+ :terms,
20
+ :punches_needed_prefix,
21
+ :purchased_item,
22
+ :punches_needed_suffix
23
23
  ]
24
24
  attr_accessor *PROPERTY_NAMES
25
25
 
26
+
26
27
  require 'perka/model/program_tier'
27
28
  require 'perka/model/program_type'
28
29
  TYPE_MAP = {
29
- :program_tier => Perka::Model::ProgramTier,
30
- :program_type => Perka::Model::ProgramType
30
+ :program_tier => Perka::Model::ProgramTier,
31
+ :program_type => Perka::Model::ProgramType
31
32
  }
32
33
 
33
34
  end
@@ -3,26 +3,27 @@
3
3
  require 'perka/model/base_entity_global'
4
4
 
5
5
  module Perka
6
- module Model
6
+ module Model
7
7
 
8
- # A program tier defines additional benefits for customers with a certain minimum
8
+ # A program tier defines additional benefits for customers with a certain minimum
9
9
  # visit count.
10
10
  class ProgramTier < BaseEntityGlobal
11
11
 
12
12
  PROPERTY_NAMES = [
13
- :merchant,
14
- :programs,
15
- :tier_traversals,
16
- :additional_perks,
17
- :points_multiplier,
18
- :visits_needed,
19
- :name
13
+ :merchant,
14
+ :programs,
15
+ :tier_traversals,
16
+ :additional_perks,
17
+ :points_multiplier,
18
+ :visits_needed,
19
+ :name
20
20
  ]
21
21
  attr_accessor *PROPERTY_NAMES
22
22
 
23
+
23
24
  require 'perka/model/merchant'
24
25
  TYPE_MAP = {
25
- :merchant => Perka::Model::Merchant
26
+ :merchant => Perka::Model::Merchant
26
27
  }
27
28
 
28
29
  end
data/lib/perka/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Perka
2
- VERSION = "1.4"
2
+ VERSION = "1.5"
3
3
  end
data/lib/perka_fast.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  # Generated File - DO NOT EDIT
2
2
 
3
3
  require "perka/client_api"
4
+ require "perka/model/customer"
4
5
  require "perka/model/points_activity"
5
6
  require "perka/model/base_entity_global"
6
7
  require "perka/model/property"
7
8
  require "perka/model/api_description"
8
9
  require "perka/model/entity_annotation"
9
10
  require "perka/model/user_credentials"
10
- require "perka/model/customer"
11
11
  require "perka/model/merchant"
12
12
  require "perka/model/abstract_user"
13
13
  require "perka/model/clerk"
@@ -15,18 +15,18 @@ require "perka/model/integrator_user"
15
15
  require "perka/model/internal_user"
16
16
  require "perka/model/merchant_user"
17
17
  require "perka/model/merchant_location"
18
- require "perka/model/reward"
19
18
  require "perka/model/reward_grant"
20
19
  require "perka/model/visit"
21
20
  require "perka/model/visit_confirmation"
22
- require "perka/model/points_catalog_item"
23
- require "perka/model/type"
24
- require "perka/model/endpoint_description"
25
- require "perka/model/entity_description"
26
21
  require "perka/model/customer_device"
22
+ require "perka/model/reward"
27
23
  require "perka/model/sms_message"
28
24
  require "perka/model/social_service_subscription"
29
25
  require "perka/model/tier_traversal"
26
+ require "perka/model/points_catalog_item"
27
+ require "perka/model/type"
28
+ require "perka/model/endpoint_description"
29
+ require "perka/model/entity_description"
30
30
  require "perka/model/program_tier"
31
31
  require "perka/model/merchant_capability"
32
32
  require "perka/model/outbound_message"
@@ -37,18 +37,17 @@ require "perka/model/sms_outbound_message"
37
37
  require "perka/model/coupon_visibility"
38
38
  require "perka/model/merchant_device"
39
39
  require "perka/model/street_address"
40
- require "perka/model/program"
41
- require "perka/model/reward_advancement"
42
40
  require "perka/model/abstract_reward_confirmation"
43
41
  require "perka/model/points_activity_confirmation"
44
42
  require "perka/model/punch_reward_confirmation"
45
43
  require "perka/model/redemption_coupon_confirmation"
46
44
  require "perka/model/redemption_reward_confirmation"
47
45
  require "perka/model/tier_traversal_confirmation"
46
+ require "perka/model/reward_advancement"
48
47
  require "perka/model/coupon_redemption"
49
48
  require "perka/model/feedback_item"
49
+ require "perka/model/program"
50
50
  require "perka/model/parameter_description"
51
- require "perka/model/coupon"
52
51
  require "perka/model/coupon_target"
53
52
  require "perka/model/bounce_back_target"
54
53
  require "perka/model/composite_target"
@@ -64,5 +63,6 @@ require "perka/model/nobody_target"
64
63
  require "perka/model/physical_redemption_target"
65
64
  require "perka/model/tier_target"
66
65
  require "perka/model/yield_management_target"
66
+ require "perka/model/coupon"
67
67
  require "perka/model/program_type"
68
68
  require "perka/model/coupon_campaign"
@@ -16,11 +16,11 @@ describe Perka::PerkaApi do
16
16
  @api = Perka::PerkaApi.new({
17
17
  :flatpack => Flatpack::Core::Flatpack.new({
18
18
  :pretty => true,
19
- :verbose => true,
19
+ :verbose => false,
20
20
  :entity_module => Perka::Model
21
21
  }),
22
22
  :server_base => API_BASE,
23
- :verbose => true
23
+ :verbose => false
24
24
  })
25
25
  @api.oauth_integrator_login(INTEGRATOR_ID, INTEGRATOR_SECRET)
26
26
  end
@@ -128,7 +128,7 @@ describe Perka::PerkaApi do
128
128
  advancement.reward.punches_earned.should eq(2)
129
129
 
130
130
  # We'll now pull down the customer's reward status
131
- rewards = @api.customer_reward_get.with_customer_uuid(customer.uuid).execute
131
+ rewards = @api.customer_uuid_get(customer.uuid).execute.rewards
132
132
 
133
133
  # We should have only one non-activated, non-redeemed reward with 2 punches
134
134
  rewards.length.should eq(1)
@@ -150,7 +150,7 @@ describe Perka::PerkaApi do
150
150
  })).execute
151
151
 
152
152
  # The customer should now one activated, and one non-activated reward
153
- rewards = @api.customer_reward_get.with_customer_uuid(customer.uuid).execute
153
+ rewards = @api.customer_uuid_get(customer.uuid).execute.rewards
154
154
  rewards.length.should eq(2)
155
155
  active_reward = rewards.detect {|r| r.activated_at }
156
156
  active_reward.activated_at.should_not be_nil
@@ -179,13 +179,56 @@ describe Perka::PerkaApi do
179
179
 
180
180
  # The customer status should now show just one non-active
181
181
  # reward with 2 punches
182
- rewards = @api.customer_reward_get.with_customer_uuid(customer.uuid).execute
182
+ rewards = @api.customer_uuid_get(customer.uuid).execute.rewards
183
183
  rewards.length.should eq(1)
184
184
  rewards.first.activated_at.should be_nil
185
185
  rewards.first.redeemed_at.should be_nil
186
186
  rewards.first.punches_earned.should eq(2)
187
187
  end
188
188
 
189
+ it "determines the status of an existing customer" do
190
+ @api.oauth_integrator_login(INTEGRATOR_ID, INTEGRATOR_SECRET)
191
+
192
+ # first set up our existing customer
193
+ cred = Perka::Model::UserCredentials.new(:email => 'joe+yet_another@getperka.com')
194
+ existing_customer = @api.integrator_customer_post(cred).execute
195
+ merchants = @api.integrator_managed_merchants_get.execute
196
+ merchant = @api.describe_entity_get(merchants.first).execute
197
+ location = merchant.merchant_locations.first
198
+ program_type = merchant.program_tiers.first.programs.first.program_type
199
+
200
+ # switch over to the clerk role
201
+ @api = @api.oauth_integrator_become("CLERK", location.uuid)
202
+
203
+ # and fetch our customer. The customer_uuid_get endpoint will
204
+ # populate the resulting customer with reward, tier_traversal, and
205
+ # available coupon information
206
+ customer = @api.customer_uuid_get(existing_customer.uuid).execute
207
+
208
+ # since this customer doesn't have any visits yet, there should be
209
+ # no tier_traversal or reward information
210
+ customer.tier_traversals.should be_nil
211
+ customer.rewards.should be_nil
212
+
213
+ # let's go ahaead and create a visit
214
+ visit = @api.customer_reward_put(Perka::Model::RewardGrant.new({
215
+ :customer => customer,
216
+ :reward_confirmations => [
217
+ Perka::Model::PunchRewardConfirmation.new({
218
+ :program_type => program_type,
219
+ :punches_earned => 1
220
+ })
221
+ ]
222
+ })).execute
223
+
224
+ # Note that since the most recent tierTraversal can be expected in the
225
+ # response, the visit can be used to check the customer's current status
226
+ # at the merchant. In this case, our customer should be in the
227
+ # lowest 'local' tier.
228
+ visit.customer.tier_traversals.length.should eq(1)
229
+ visit.customer.tier_traversals.first.program_tier.name.should eq('local')
230
+ end
231
+
189
232
  it "annotate entities with arbitrary JSON data" do
190
233
  @api.oauth_integrator_login(INTEGRATOR_ID, INTEGRATOR_SECRET)
191
234
 
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perka
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 4
9
- version: "1.4"
8
+ - 5
9
+ version: "1.5"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joe Stelmach
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-10-14 00:00:00 +05:30
17
+ date: 2012-10-17 00:00:00 +05:30
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency