Class: EasyPost::Services::ReferralCustomer
- Defined in:
- lib/easypost/services/referral_customer.rb
Constant Summary collapse
Instance Method Summary collapse
-
#add_credit_card(referral_api_key, number, expiration_month, expiration_year, cvc, priority = 'primary') ⇒ Object
Add credit card to a referral customer.
-
#all(params = {}) ⇒ Object
Retrieve a list of referral customers.
-
#create(params = {}) ⇒ Object
Create a referral customer.
-
#get_next_page(collection, page_size = nil) ⇒ Object
Get the next page of referral customers.
-
#update_email(user_id, email) ⇒ Object
Update a referral customer.
Methods inherited from Service
Constructor Details
This class inherits a constructor from EasyPost::Services::Service
Instance Method Details
#add_credit_card(referral_api_key, number, expiration_month, expiration_year, cvc, priority = 'primary') ⇒ Object
Add credit card to a referral customer. This function requires the ReferralCustomer Customer’s API key.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/easypost/services/referral_customer.rb', line 35 def add_credit_card(referral_api_key, number, expiration_month, expiration_year, cvc, priority = 'primary') easypost_stripe_api_key = retrieve_easypost_stripe_api_key begin stripe_credit_card_token = create_stripe_token( number, expiration_month, expiration_year, cvc, easypost_stripe_api_key, ) rescue StandardError raise EasyPost::Errors::ExternalApiError.new(EasyPost::Constants::STRIPE_CARD_CREATE_FAILED) end create_easypost_credit_card(referral_api_key, stripe_credit_card_token, priority) end |
#all(params = {}) ⇒ Object
Retrieve a list of referral customers. This function requires the Partner User’s API key.
25 26 27 |
# File 'lib/easypost/services/referral_customer.rb', line 25 def all(params = {}) @client.make_request(:get, 'referral_customers', MODEL_CLASS, params) end |
#create(params = {}) ⇒ Object
Create a referral customer. This function requires the Partner User’s API key.
7 8 9 |
# File 'lib/easypost/services/referral_customer.rb', line 7 def create(params = {}) @client.make_request(:post, 'referral_customers', MODEL_CLASS, { user: params }) end |
#get_next_page(collection, page_size = nil) ⇒ Object
Get the next page of referral customers.
30 31 32 |
# File 'lib/easypost/services/referral_customer.rb', line 30 def get_next_page(collection, page_size = nil) get_next_page_helper(collection, collection.referral_customers, 'referral_customers', MODEL_CLASS, page_size) end |
#update_email(user_id, email) ⇒ Object
Update a referral customer. This function requires the Partner User’s API key.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/easypost/services/referral_customer.rb', line 12 def update_email(user_id, email) wrapped_params = { user: { email: email, }, } @client.make_request(:put, "referral_customers/#{user_id}", MODEL_CLASS, wrapped_params) # return true if API succeeds, else an error is throw if it fails. true end |