Class: Ryext::Models::Subscription

Inherits:
Object
  • Object
show all
Extended by:
Finder
Includes:
Model
Defined in:
lib/ryext/models/subscription.rb

Constant Summary collapse

COLLECTION_KEY =
'subscriptions'
YEXT_ATTRIBUTES =
{
  id: 'id',
  customer_id: 'customerId',
  offer_id: 'offerId',
  location_ids: 'locationIds',
  expiring_location_ids: 'expiringLocationIds',
  status: 'status',
  start_date: 'startDate',
  paid_through_date: 'paidThroughDate',
  features: 'features'
}

Class Method Summary collapse

Methods included from Finder

all, base_uri, base_url, collection_from, get, instance_klass

Methods included from Model

#build, included, #initialize, #instance_klass

Class Method Details

.clean_params(params) ⇒ Object



19
20
21
# File 'lib/ryext/models/subscription.rb', line 19

def self.clean_params(params)
  params.reject { |k| ['customerId', 'subscriptionId'].include? k }
end

.default_path(params) ⇒ Object



8
9
10
11
# File 'lib/ryext/models/subscription.rb', line 8

def self.default_path(params)
  customer_id = params['customerId']
  path(params) || "/customers/#{customer_id}/subscriptions"
end

.path(params) ⇒ Object



13
14
15
16
17
# File 'lib/ryext/models/subscription.rb', line 13

def self.path(params)
  customer_id = params['customerId']
  subscription_id = params['subscriptionId']
  "/customers/#{customer_id}/subscriptions/#{subscription_id}" unless customer_id.nil? || subscription_id.nil?
end