perka 1.0.pre
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/.gitignore +7 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +201 -0
- data/README.md +17 -0
- data/Rakefile +70 -0
- data/lib/perka/client_api.rb +260 -0
- data/lib/perka/model/abstract_reward_confirmation.rb +15 -0
- data/lib/perka/model/abstract_user.rb +37 -0
- data/lib/perka/model/api_description.rb +22 -0
- data/lib/perka/model/base_entity_global.rb +27 -0
- data/lib/perka/model/bounce_back_target.rb +33 -0
- data/lib/perka/model/canned_email_outbound_message.rb +14 -0
- data/lib/perka/model/clerk.rb +41 -0
- data/lib/perka/model/composite_target.rb +22 -0
- data/lib/perka/model/console_message.rb +16 -0
- data/lib/perka/model/coupon.rb +52 -0
- data/lib/perka/model/coupon_campaign.rb +26 -0
- data/lib/perka/model/coupon_redemption.rb +26 -0
- data/lib/perka/model/coupon_target.rb +30 -0
- data/lib/perka/model/coupon_visibility.rb +29 -0
- data/lib/perka/model/customer.rb +41 -0
- data/lib/perka/model/customer_device.rb +23 -0
- data/lib/perka/model/endpoint_description.rb +49 -0
- data/lib/perka/model/entity_annotation.rb +33 -0
- data/lib/perka/model/entity_description.rb +31 -0
- data/lib/perka/model/everybody_target.rb +15 -0
- data/lib/perka/model/feedback_item.rb +28 -0
- data/lib/perka/model/first_visit_target.rb +16 -0
- data/lib/perka/model/idle_customer_target.rb +20 -0
- data/lib/perka/model/integrator_user.rb +16 -0
- data/lib/perka/model/internal_user.rb +15 -0
- data/lib/perka/model/like_to_unlock_target.rb +14 -0
- data/lib/perka/model/list_target.rb +17 -0
- data/lib/perka/model/merchant.rb +42 -0
- data/lib/perka/model/merchant_capability.rb +16 -0
- data/lib/perka/model/merchant_device.rb +29 -0
- data/lib/perka/model/merchant_location.rb +46 -0
- data/lib/perka/model/merchant_user.rb +29 -0
- data/lib/perka/model/nobody_target.rb +15 -0
- data/lib/perka/model/outbound_message.rb +14 -0
- data/lib/perka/model/parameter_description.rb +29 -0
- data/lib/perka/model/participation_target.rb +34 -0
- data/lib/perka/model/physical_redemption_target.rb +17 -0
- data/lib/perka/model/points_activity.rb +34 -0
- data/lib/perka/model/points_activity_confirmation.rb +24 -0
- data/lib/perka/model/points_catalog_item.rb +41 -0
- data/lib/perka/model/program.rb +35 -0
- data/lib/perka/model/program_tier.rb +30 -0
- data/lib/perka/model/program_type.rb +27 -0
- data/lib/perka/model/property.rb +65 -0
- data/lib/perka/model/punch_reward_confirmation.rb +43 -0
- data/lib/perka/model/push_message.rb +17 -0
- data/lib/perka/model/redemption_coupon_confirmation.rb +26 -0
- data/lib/perka/model/redemption_reward_confirmation.rb +26 -0
- data/lib/perka/model/reward.rb +38 -0
- data/lib/perka/model/reward_advancement.rb +30 -0
- data/lib/perka/model/reward_grant.rb +37 -0
- data/lib/perka/model/sms_message.rb +15 -0
- data/lib/perka/model/sms_outbound_message.rb +14 -0
- data/lib/perka/model/social_list_target.rb +14 -0
- data/lib/perka/model/social_service_subscription.rb +26 -0
- data/lib/perka/model/street_address.rb +27 -0
- data/lib/perka/model/tier_target.rb +24 -0
- data/lib/perka/model/tier_traversal.rb +30 -0
- data/lib/perka/model/tier_traversal_confirmation.rb +28 -0
- data/lib/perka/model/type.rb +33 -0
- data/lib/perka/model/user_credentials.rb +28 -0
- data/lib/perka/model/visit.rb +59 -0
- data/lib/perka/model/visit_confirmation.rb +47 -0
- data/lib/perka/model/weather_target.rb +27 -0
- data/lib/perka/model/yield_management_target.rb +23 -0
- data/lib/perka/perka_api.rb +89 -0
- data/lib/perka/version.rb +3 -0
- data/lib/perka.rb +6 -0
- data/lib/perka_fast.rb +68 -0
- data/perka.gemspec +20 -0
- data/spec/api_integrator_spec.rb +210 -0
- data/spec/model_spec.rb +24 -0
- metadata +178 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
# Generated File - DO NOT EDIT
|
2
|
+
|
3
|
+
require 'flatpack_core'
|
4
|
+
|
5
|
+
module Perka
|
6
|
+
module Model
|
7
|
+
|
8
|
+
# Encapsulates one or more <entityReference payloadName='abstractRewardConfirmation'>
|
9
|
+
# AbstractRewardConfirmation</entityReference> objects to be given to a customer.
|
10
|
+
# <p> This differs from a <entityReference payloadName='visitConfirmation'>
|
11
|
+
# VisitConfirmation</entityReference> in that there's no previously-created
|
12
|
+
# Visit object to confirm. Instead, a RewardGrant will create a confirmed Visit
|
13
|
+
# and possibly create a Customer object based on an email address or SMS phone
|
14
|
+
# number. The UUID of the Visit object will be set to the RewardGrant's UUID
|
15
|
+
# to allow post-grant correlation. <p> Exactly one of <entityReference payloadName='rewardGrant'>
|
16
|
+
# #getCustomerEmail()</entityReference>, <entityReference payloadName='rewardGrant'>
|
17
|
+
# #getCustomerPhone()</entityReference>, or <entityReference payloadName='rewardGrant'>
|
18
|
+
# #getCustomerUuid()</entityReference> must be provided to identify the customer.
|
19
|
+
class RewardGrant < Flatpack::Core::BaseHasUuid
|
20
|
+
|
21
|
+
PROPERTY_NAMES = [
|
22
|
+
:customer,
|
23
|
+
|
24
|
+
# At least one <entityReference payloadName='abstractRewardConfirmation'>
|
25
|
+
# AbstractRewardConfirmation</entityReference> must be given.
|
26
|
+
:reward_confirmations
|
27
|
+
]
|
28
|
+
attr_accessor *PROPERTY_NAMES
|
29
|
+
|
30
|
+
require 'perka/model/customer'
|
31
|
+
TYPE_MAP = {
|
32
|
+
:customer => Perka::Model::Customer
|
33
|
+
}
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Generated File - DO NOT EDIT
|
2
|
+
|
3
|
+
require 'perka/model/base_entity_global'
|
4
|
+
|
5
|
+
module Perka
|
6
|
+
module Model
|
7
|
+
|
8
|
+
# Represents a customer's preference to have a specific social event posted
|
9
|
+
# to a specific social backend.
|
10
|
+
class SocialServiceSubscription < BaseEntityGlobal
|
11
|
+
|
12
|
+
PROPERTY_NAMES = [
|
13
|
+
:customer,
|
14
|
+
:social_action,
|
15
|
+
:social_service
|
16
|
+
]
|
17
|
+
attr_accessor *PROPERTY_NAMES
|
18
|
+
|
19
|
+
require 'perka/model/customer'
|
20
|
+
TYPE_MAP = {
|
21
|
+
:customer => Perka::Model::Customer
|
22
|
+
}
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Generated File - DO NOT EDIT
|
2
|
+
|
3
|
+
require 'flatpack_core'
|
4
|
+
|
5
|
+
module Perka
|
6
|
+
module Model
|
7
|
+
|
8
|
+
# A simple representation of a mailing address. It is intended to be used as
|
9
|
+
# a payload carrier object or as an embeddable JPA object. <p> All of the properties
|
10
|
+
# in this object are marked as PermitAll because access to the StreetAddress
|
11
|
+
# itself is controlled by the enclosing object.
|
12
|
+
class StreetAddress < Flatpack::Core::BaseHasUuid
|
13
|
+
|
14
|
+
PROPERTY_NAMES = [
|
15
|
+
:address_2,
|
16
|
+
:city,
|
17
|
+
:zip,
|
18
|
+
:address,
|
19
|
+
:state,
|
20
|
+
:country
|
21
|
+
]
|
22
|
+
attr_accessor *PROPERTY_NAMES
|
23
|
+
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Generated File - DO NOT EDIT
|
2
|
+
|
3
|
+
require 'perka/model/coupon_target'
|
4
|
+
|
5
|
+
module Perka
|
6
|
+
module Model
|
7
|
+
|
8
|
+
# Makes coupons available to customers who are members of a given <entityReference
|
9
|
+
# payloadName='programTier'> ProgramTier</entityReference>.
|
10
|
+
class TierTarget < CouponTarget
|
11
|
+
|
12
|
+
PROPERTY_NAMES = [
|
13
|
+
:program_tier
|
14
|
+
]
|
15
|
+
attr_accessor *PROPERTY_NAMES
|
16
|
+
|
17
|
+
require 'perka/model/program_tier'
|
18
|
+
TYPE_MAP = {
|
19
|
+
:program_tier => Perka::Model::ProgramTier
|
20
|
+
}
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Generated File - DO NOT EDIT
|
2
|
+
|
3
|
+
require 'perka/model/base_entity_global'
|
4
|
+
|
5
|
+
module Perka
|
6
|
+
module Model
|
7
|
+
|
8
|
+
# Maps a <entityReference payloadName='customer'> Customer</entityReference>
|
9
|
+
# to a <entityReference payloadName='programTier'> ProgramTier</entityReference>
|
10
|
+
# and provides the total number of validated visits to the associated <entityReference
|
11
|
+
# payloadName='merchant'> Merchant</entityReference>.
|
12
|
+
class TierTraversal < BaseEntityGlobal
|
13
|
+
|
14
|
+
PROPERTY_NAMES = [
|
15
|
+
:customer,
|
16
|
+
:program_tier,
|
17
|
+
:visit_count
|
18
|
+
]
|
19
|
+
attr_accessor *PROPERTY_NAMES
|
20
|
+
|
21
|
+
require 'perka/model/program_tier'
|
22
|
+
require 'perka/model/customer'
|
23
|
+
TYPE_MAP = {
|
24
|
+
:program_tier => Perka::Model::ProgramTier,
|
25
|
+
:customer => Perka::Model::Customer
|
26
|
+
}
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Generated File - DO NOT EDIT
|
2
|
+
|
3
|
+
require 'perka/model/abstract_reward_confirmation'
|
4
|
+
|
5
|
+
module Perka
|
6
|
+
module Model
|
7
|
+
|
8
|
+
# Allows a customer to be placed in an arbitrary program tier. This confirmation
|
9
|
+
# type may be used to demote a customer to a lower tier if the customer does
|
10
|
+
# not meet the visit count requirement for membership in its current tier.
|
11
|
+
class TierTraversalConfirmation < AbstractRewardConfirmation
|
12
|
+
|
13
|
+
PROPERTY_NAMES = [
|
14
|
+
|
15
|
+
# The ProgramTier that the customer associated with the visit should be
|
16
|
+
# moved into.
|
17
|
+
:program_tier
|
18
|
+
]
|
19
|
+
attr_accessor *PROPERTY_NAMES
|
20
|
+
|
21
|
+
require 'perka/model/program_tier'
|
22
|
+
TYPE_MAP = {
|
23
|
+
:program_tier => Perka::Model::ProgramTier
|
24
|
+
}
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Generated File - DO NOT EDIT
|
2
|
+
|
3
|
+
require 'flatpack_core'
|
4
|
+
|
5
|
+
module Perka
|
6
|
+
module Model
|
7
|
+
|
8
|
+
# A simple JSON type description.
|
9
|
+
class Type < Flatpack::Core::BaseHasUuid
|
10
|
+
|
11
|
+
PROPERTY_NAMES = [
|
12
|
+
:json_kind,
|
13
|
+
:enum_values,
|
14
|
+
:list_element,
|
15
|
+
:map_key,
|
16
|
+
:map_value,
|
17
|
+
:type_hint,
|
18
|
+
:name
|
19
|
+
]
|
20
|
+
attr_accessor *PROPERTY_NAMES
|
21
|
+
|
22
|
+
require 'perka/model/type'
|
23
|
+
require 'perka/model/type'
|
24
|
+
require 'perka/model/type'
|
25
|
+
TYPE_MAP = {
|
26
|
+
:map_key => Perka::Model::Type,
|
27
|
+
:list_element => Perka::Model::Type,
|
28
|
+
:map_value => Perka::Model::Type
|
29
|
+
}
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Generated File - DO NOT EDIT
|
2
|
+
|
3
|
+
require 'flatpack_core'
|
4
|
+
|
5
|
+
module Perka
|
6
|
+
module Model
|
7
|
+
|
8
|
+
# A transfer object used to hold data related to account creation and maintenance.
|
9
|
+
class UserCredentials < Flatpack::Core::BaseHasUuid
|
10
|
+
|
11
|
+
PROPERTY_NAMES = [
|
12
|
+
:email,
|
13
|
+
:first_name,
|
14
|
+
:last_name,
|
15
|
+
:new_password,
|
16
|
+
:new_password_confirmation,
|
17
|
+
:phone,
|
18
|
+
:phone_confirmation_code,
|
19
|
+
:current_password,
|
20
|
+
:hmac,
|
21
|
+
:user_uuid
|
22
|
+
]
|
23
|
+
attr_accessor *PROPERTY_NAMES
|
24
|
+
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Generated File - DO NOT EDIT
|
2
|
+
|
3
|
+
require 'perka/model/base_entity_global'
|
4
|
+
|
5
|
+
module Perka
|
6
|
+
module Model
|
7
|
+
|
8
|
+
# Represents a check-in at a <entityReference payloadName='merchantLocation'>
|
9
|
+
# MerchantLocation</entityReference> by a <entityReference payloadName='customer'>
|
10
|
+
# Customer</entityReference>.
|
11
|
+
class Visit < BaseEntityGlobal
|
12
|
+
|
13
|
+
PROPERTY_NAMES = [
|
14
|
+
:customer,
|
15
|
+
|
16
|
+
# Where the Visit occurred.
|
17
|
+
:merchant_location,
|
18
|
+
|
19
|
+
# Indicates that the Visit was created via the SMS endpoint and not from
|
20
|
+
# an app.
|
21
|
+
:sms,
|
22
|
+
|
23
|
+
# The latest <entityReference payloadName='pointsActivity'> PointsActivity</entityReference>
|
24
|
+
# for the Visit's <entityReference payloadName='customer'> Customer</entityReference>
|
25
|
+
# at the <entityReference payloadName='merchantLocation'> MerchantLocation</entityReference>.
|
26
|
+
# This may be null if the customer has no previous points activity at the
|
27
|
+
# merchant.
|
28
|
+
:current_points_activity,
|
29
|
+
|
30
|
+
# The punches earned during the Visit, broken out by <entityReference payloadName='reward'>
|
31
|
+
# Reward</entityReference>.
|
32
|
+
:reward_advancements,
|
33
|
+
|
34
|
+
# The time at which the visit was confirmed by the clerk.
|
35
|
+
:validated_at,
|
36
|
+
|
37
|
+
# The <entityReference payloadName='coupon'> Coupons</entityReference> that
|
38
|
+
# were redeemed during the visit.
|
39
|
+
:coupon_redemptions,
|
40
|
+
|
41
|
+
# Any feedback left by the Customer after the Visit was validated.
|
42
|
+
:feedback_item
|
43
|
+
]
|
44
|
+
attr_accessor *PROPERTY_NAMES
|
45
|
+
|
46
|
+
require 'perka/model/feedback_item'
|
47
|
+
require 'perka/model/points_activity'
|
48
|
+
require 'perka/model/merchant_location'
|
49
|
+
require 'perka/model/customer'
|
50
|
+
TYPE_MAP = {
|
51
|
+
:feedback_item => Perka::Model::FeedbackItem,
|
52
|
+
:current_points_activity => Perka::Model::PointsActivity,
|
53
|
+
:merchant_location => Perka::Model::MerchantLocation,
|
54
|
+
:customer => Perka::Model::Customer
|
55
|
+
}
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Generated File - DO NOT EDIT
|
2
|
+
|
3
|
+
require 'flatpack_core'
|
4
|
+
|
5
|
+
module Perka
|
6
|
+
module Model
|
7
|
+
|
8
|
+
# Confirms a previously-created <entityReference payloadName='visit'> Visit</entityReference>
|
9
|
+
# that was the result of a <entityReference payloadName='customer'> Customer</entityReference>
|
10
|
+
# checking into a location.
|
11
|
+
class VisitConfirmation < Flatpack::Core::BaseHasUuid
|
12
|
+
|
13
|
+
PROPERTY_NAMES = [
|
14
|
+
|
15
|
+
# The <entityReference payloadName='customer'> Customer</entityReference>
|
16
|
+
# associated with the <entityReference payloadName='visit'> Visit</entityReference>.
|
17
|
+
# This property is usually inferred from the associated <entityReference
|
18
|
+
# payloadName='visit'> Visit</entityReference>.
|
19
|
+
:customer,
|
20
|
+
|
21
|
+
# The <entityReference payloadName='merchant'> Merchant</entityReference>
|
22
|
+
# associated with the <entityReference payloadName='visit'> Visit</entityReference>.
|
23
|
+
# This property is usually inferred from the associated <entityReference
|
24
|
+
# payloadName='visit'> Visit</entityReference>.
|
25
|
+
:merchant,
|
26
|
+
|
27
|
+
# The previously-created <entityReference payloadName='visit'> Visit</entityReference>
|
28
|
+
# that is associated with a customer checkin.
|
29
|
+
:visit,
|
30
|
+
|
31
|
+
# The rewards associated with the visit (e.g. punches earned, coupons redeemed).
|
32
|
+
:reward_confirmations
|
33
|
+
]
|
34
|
+
attr_accessor *PROPERTY_NAMES
|
35
|
+
|
36
|
+
require 'perka/model/merchant'
|
37
|
+
require 'perka/model/visit'
|
38
|
+
require 'perka/model/customer'
|
39
|
+
TYPE_MAP = {
|
40
|
+
:merchant => Perka::Model::Merchant,
|
41
|
+
:visit => Perka::Model::Visit,
|
42
|
+
:customer => Perka::Model::Customer
|
43
|
+
}
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Generated File - DO NOT EDIT
|
2
|
+
|
3
|
+
require 'perka/model/list_target'
|
4
|
+
|
5
|
+
module Perka
|
6
|
+
module Model
|
7
|
+
|
8
|
+
class WeatherTarget < ListTarget
|
9
|
+
|
10
|
+
PROPERTY_NAMES = [
|
11
|
+
:operation,
|
12
|
+
:metric,
|
13
|
+
:threshold,
|
14
|
+
|
15
|
+
# The local minutes-of-day after which the availability of the coupon will
|
16
|
+
# not change for the remainder of the day.
|
17
|
+
:local_decision_at,
|
18
|
+
|
19
|
+
# The time of day for which the metric threshold must be met.
|
20
|
+
:local_metric_at
|
21
|
+
]
|
22
|
+
attr_accessor *PROPERTY_NAMES
|
23
|
+
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Generated File - DO NOT EDIT
|
2
|
+
|
3
|
+
require 'perka/model/coupon_target'
|
4
|
+
|
5
|
+
module Perka
|
6
|
+
module Model
|
7
|
+
|
8
|
+
class YieldManagementTarget < CouponTarget
|
9
|
+
|
10
|
+
PROPERTY_NAMES = [
|
11
|
+
|
12
|
+
# Returns the minutes-of-day that the redemption window closes.
|
13
|
+
:local_redemption_end_at,
|
14
|
+
|
15
|
+
# Returns the minutes-of-day that the redemption window opens.
|
16
|
+
:local_redemption_start_at
|
17
|
+
]
|
18
|
+
attr_accessor *PROPERTY_NAMES
|
19
|
+
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'flatpack_core'
|
2
|
+
|
3
|
+
module Perka
|
4
|
+
class PerkaApi < Perka::ClientApi
|
5
|
+
|
6
|
+
include Flatpack::Core::MapInitialize
|
7
|
+
|
8
|
+
attr_accessor :access_token, :access_expiration, :refresh_token, :user_uuid
|
9
|
+
|
10
|
+
# our session is considered active if we've never received an access
|
11
|
+
# token, or our token expiration as after now
|
12
|
+
def session_active?
|
13
|
+
!@access_token or @access_expiration > Time.now
|
14
|
+
end
|
15
|
+
|
16
|
+
def refresh_session
|
17
|
+
oauth_refresh_token
|
18
|
+
end
|
19
|
+
|
20
|
+
# Concrete implementations that require authentication should implement
|
21
|
+
# this method if authenticated requests require custom request headers
|
22
|
+
def auth_headers
|
23
|
+
@access_token ? {'Authorization' => "Bearer #{@access_token}"} : {}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Grants an integrator access token
|
27
|
+
def oauth_integrator_login(integrator_id, integrator_secret)
|
28
|
+
@integrator_id = integrator_id
|
29
|
+
@integrator_secret = integrator_secret
|
30
|
+
payload =
|
31
|
+
"grant_type=password"\
|
32
|
+
"&username=#{integrator_id}"\
|
33
|
+
"&client_id=#{integrator_id}"\
|
34
|
+
"&password=#{URI::encode(integrator_secret)}"\
|
35
|
+
"&scope=INTEGRATOR";
|
36
|
+
|
37
|
+
execute_token_request(self, payload);
|
38
|
+
end
|
39
|
+
|
40
|
+
# returns a new PerkaApi authorized as the given role and user
|
41
|
+
def oauth_integrator_become(role, uuid)
|
42
|
+
role = role
|
43
|
+
payload = "grant_type=client_credentials&scope=#{URI::encode(role)}:#{uuid}"
|
44
|
+
new_api = PerkaApi.new({
|
45
|
+
:server_base => @server_base,
|
46
|
+
:flatpack => @flatpack,
|
47
|
+
:access_token => @access_token,
|
48
|
+
:access_expiration => @access_expiration,
|
49
|
+
:verbose => @verbose,
|
50
|
+
})
|
51
|
+
execute_token_request(new_api, payload)
|
52
|
+
new_api
|
53
|
+
end
|
54
|
+
|
55
|
+
# Obtain a new access token using integrator credentials and a refresh token.
|
56
|
+
def oauth_refresh_token
|
57
|
+
payload = "grant_type=refresh_token"\
|
58
|
+
"&client_id=#{@integrator_id}"\
|
59
|
+
"&client_secret=#{URI::encode(@integrator_secret)}"\
|
60
|
+
"&refresh_token=#{@refresh_token}"
|
61
|
+
|
62
|
+
execute_token_request(self, payload);
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def execute_token_request(api, payload)
|
68
|
+
json = TokenRequest.new(api, payload).execute
|
69
|
+
status = json['status_code']
|
70
|
+
expires = json['expires_in']
|
71
|
+
api.access_expiration = Time.now + expires.to_i if expires
|
72
|
+
api.access_token = json['access_token']
|
73
|
+
api.refresh_token = json['refresh_token']
|
74
|
+
uuid = json['uuid']
|
75
|
+
api.user_uuid = uuid if uuid
|
76
|
+
end
|
77
|
+
|
78
|
+
class TokenRequest < Flatpack::Client::JsonRequest
|
79
|
+
attr_accessor :payload
|
80
|
+
|
81
|
+
def initialize(api, payload)
|
82
|
+
@payload = payload
|
83
|
+
super(api, "POST", "/api/2/auth/token");
|
84
|
+
header("Content-Type", "application/x-www-form-urlencoded");
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
data/lib/perka.rb
ADDED
data/lib/perka_fast.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Generated File - DO NOT EDIT
|
2
|
+
|
3
|
+
require "perka/client_api"
|
4
|
+
require "perka/model/points_activity"
|
5
|
+
require "perka/model/base_entity_global"
|
6
|
+
require "perka/model/property"
|
7
|
+
require "perka/model/api_description"
|
8
|
+
require "perka/model/entity_annotation"
|
9
|
+
require "perka/model/user_credentials"
|
10
|
+
require "perka/model/customer"
|
11
|
+
require "perka/model/merchant"
|
12
|
+
require "perka/model/abstract_user"
|
13
|
+
require "perka/model/clerk"
|
14
|
+
require "perka/model/integrator_user"
|
15
|
+
require "perka/model/internal_user"
|
16
|
+
require "perka/model/merchant_user"
|
17
|
+
require "perka/model/merchant_location"
|
18
|
+
require "perka/model/reward"
|
19
|
+
require "perka/model/reward_grant"
|
20
|
+
require "perka/model/visit"
|
21
|
+
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
|
+
require "perka/model/customer_device"
|
27
|
+
require "perka/model/sms_message"
|
28
|
+
require "perka/model/social_service_subscription"
|
29
|
+
require "perka/model/tier_traversal"
|
30
|
+
require "perka/model/program_tier"
|
31
|
+
require "perka/model/merchant_capability"
|
32
|
+
require "perka/model/outbound_message"
|
33
|
+
require "perka/model/canned_email_outbound_message"
|
34
|
+
require "perka/model/console_message"
|
35
|
+
require "perka/model/push_message"
|
36
|
+
require "perka/model/sms_outbound_message"
|
37
|
+
require "perka/model/coupon_visibility"
|
38
|
+
require "perka/model/merchant_device"
|
39
|
+
require "perka/model/street_address"
|
40
|
+
require "perka/model/program"
|
41
|
+
require "perka/model/reward_advancement"
|
42
|
+
require "perka/model/abstract_reward_confirmation"
|
43
|
+
require "perka/model/points_activity_confirmation"
|
44
|
+
require "perka/model/punch_reward_confirmation"
|
45
|
+
require "perka/model/redemption_coupon_confirmation"
|
46
|
+
require "perka/model/redemption_reward_confirmation"
|
47
|
+
require "perka/model/tier_traversal_confirmation"
|
48
|
+
require "perka/model/coupon_redemption"
|
49
|
+
require "perka/model/feedback_item"
|
50
|
+
require "perka/model/parameter_description"
|
51
|
+
require "perka/model/coupon"
|
52
|
+
require "perka/model/coupon_target"
|
53
|
+
require "perka/model/bounce_back_target"
|
54
|
+
require "perka/model/composite_target"
|
55
|
+
require "perka/model/everybody_target"
|
56
|
+
require "perka/model/like_to_unlock_target"
|
57
|
+
require "perka/model/first_visit_target"
|
58
|
+
require "perka/model/idle_customer_target"
|
59
|
+
require "perka/model/list_target"
|
60
|
+
require "perka/model/participation_target"
|
61
|
+
require "perka/model/social_list_target"
|
62
|
+
require "perka/model/weather_target"
|
63
|
+
require "perka/model/nobody_target"
|
64
|
+
require "perka/model/physical_redemption_target"
|
65
|
+
require "perka/model/tier_target"
|
66
|
+
require "perka/model/yield_management_target"
|
67
|
+
require "perka/model/program_type"
|
68
|
+
require "perka/model/coupon_campaign"
|
data/perka.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/perka/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Joe Stelmach"]
|
6
|
+
gem.email = ["joe@getperka.com"]
|
7
|
+
gem.description = %q{Write a gem description}
|
8
|
+
gem.summary = %q{Write a gem summary}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "perka"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Perka::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency "rspec", "~> 2.6"
|
19
|
+
gem.add_dependency("flatpack_client", "=1.0.pre")
|
20
|
+
end
|