Class: EasyPost::Beta::Referral
- Inherits:
-
Resource
- Object
- EasyPostObject
- Resource
- EasyPost::Beta::Referral
- Defined in:
- lib/easypost/beta/referral.rb
Overview
Referral objects are User objects created from a Partner user.
Instance Attribute Summary
Attributes inherited from EasyPostObject
#api_key, #name, #parent, #unsaved_values
Class Method Summary collapse
-
.add_credit_card(referral_api_key, number, expiration_month, expiration_year, cvc, priority = 'primary') ⇒ Object
Add credit card to a referral user.
-
.all(params = {}, api_key = nil) ⇒ Object
Retrieve a list of referral users.
-
.create(params = {}, api_key = nil) ⇒ Object
Create a referral user.
-
.update_email(email, user_id, api_key = nil) ⇒ Object
Update a referral user.
Methods inherited from Resource
class_name, #delete, each, #refresh, retrieve, #save, url, #url
Methods inherited from EasyPostObject
#[], #[]=, #as_json, construct_from, #deconstruct_keys, #each, #id, #id=, #initialize, #inspect, #keys, #refresh_from, #to_hash, #to_json, #to_s, #values
Constructor Details
This class inherits a constructor from EasyPost::EasyPostObject
Class Method Details
.add_credit_card(referral_api_key, number, expiration_month, expiration_year, cvc, priority = 'primary') ⇒ Object
Add credit card to a referral user. This function requires the Referral User's API key. DEPRECATED: Please use Referral
in the main namespace instead.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/easypost/beta/referral.rb', line 38 def self.add_credit_card(referral_api_key, number, expiration_month, expiration_year, cvc, priority = 'primary') warn '[DEPRECATION] Please use `EndShipper.add_credit_card` in the main namespace instead.' 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::Error.new('Could not send card details to Stripe, please try again later.') end response = create_easypost_credit_card(referral_api_key, stripe_credit_card_token, priority) EasyPost::Util.convert_to_easypost_object(response, referral_api_key) end |
.all(params = {}, api_key = nil) ⇒ Object
Retrieve a list of referral users. This function requires the Partner User's API key. DEPRECATED: Please use Referral
in the main namespace instead.
30 31 32 33 34 |
# File 'lib/easypost/beta/referral.rb', line 30 def self.all(params = {}, api_key = nil) warn '[DEPRECATION] Please use `EndShipper.all` in the main namespace instead.' response = EasyPost.make_request(:get, '/beta/referral_customers', api_key, params) EasyPost::Util.convert_to_easypost_object(response, api_key) end |
.create(params = {}, api_key = nil) ⇒ Object
Create a referral user. This function requires the Partner User's API key. DEPRECATED: Please use Referral
in the main namespace instead.
7 8 9 10 11 |
# File 'lib/easypost/beta/referral.rb', line 7 def self.create(params = {}, api_key = nil) warn '[DEPRECATION] Please use `EndShipper.create` in the main namespace instead.' response = EasyPost.make_request(:post, '/beta/referral_customers', api_key, { user: params }) EasyPost::Util.convert_to_easypost_object(response, api_key) end |
.update_email(email, user_id, api_key = nil) ⇒ Object
Update a referral user. This function requires the Partner User's API key. DEPRECATED: Please use Referral
in the main namespace instead.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/easypost/beta/referral.rb', line 15 def self.update_email(email, user_id, api_key = nil) warn '[DEPRECATION] Please use `EndShipper.update_email` in the main namespace instead.' wrapped_params = { user: { email: email, }, } EasyPost.make_request(:put, "/beta/referral_customers/#{user_id}", api_key, wrapped_params) # return true if API succeeds, else an error is throw if it fails. true end |