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 customer.
-
.add_payment_method(stripe_customer_id, payment_method_reference, priority = 'primary', api_key = nil) ⇒ EasyPost::PaymentMethod
Add a Stripe payment method to a Referral Customer.
-
.all(params = {}, api_key = nil) ⇒ Object
Retrieve a list of referral customers.
-
.create(params = {}, api_key = nil) ⇒ Object
Create a referral customer.
-
.refund_by_amount(amount, api_key = nil) ⇒ EasyPost::Beta::PaymentRefund
Refund a Referral Customer’s wallet by a specified amount.
-
.refund_by_payment_log(payment_log_id, api_key = nil) ⇒ EasyPost::Beta::PaymentRefund
Refund a Referral Customer’s wallet for a specified payment log entry.
-
.update_email(email, user_id, api_key = nil) ⇒ Object
Update a referral customer.
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 customer. This function requires the Referral Customer’s API key. DEPRECATED: Please use Referral in the main namespace instead.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/easypost/beta/referral.rb', line 91 def self.add_credit_card(referral_api_key, number, expiration_month, expiration_year, cvc, priority = 'primary') warn '[DEPRECATION] Please use `Referral.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 |
.add_payment_method(stripe_customer_id, payment_method_reference, priority = 'primary', api_key = nil) ⇒ EasyPost::PaymentMethod
Add a Stripe payment method to a Referral Customer. This function requires the Referral Customer’s API key. noinspection RubyParameterNamingConvention
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/easypost/beta/referral.rb', line 118 def self.add_payment_method(stripe_customer_id, payment_method_reference, priority = 'primary', api_key = nil) wrapped_params = { payment_method: { stripe_customer_id: stripe_customer_id, payment_method_reference: payment_method_reference, priority: priority.downcase, }, } response = EasyPost.make_request(:post, '/beta/referral_customers/payment_method', api_key, wrapped_params) # noinspection RubyMismatchedReturnType EasyPost::Util.convert_to_easypost_object(response, api_key) end |
.all(params = {}, api_key = nil) ⇒ Object
Retrieve a list of referral customers. This function requires the Partner User’s API key. DEPRECATED: Please use Referral in the main namespace instead.
83 84 85 86 87 |
# File 'lib/easypost/beta/referral.rb', line 83 def self.all(params = {}, api_key = nil) warn '[DEPRECATION] Please use `Referral.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 customer. This function requires the Partner User’s API key. DEPRECATED: Please use Referral in the main namespace instead.
60 61 62 63 64 |
# File 'lib/easypost/beta/referral.rb', line 60 def self.create(params = {}, api_key = nil) warn '[DEPRECATION] Please use `Referral.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 |
.refund_by_amount(amount, api_key = nil) ⇒ EasyPost::Beta::PaymentRefund
Refund a Referral Customer’s wallet by a specified amount. Refund will be issued to the user’s original payment method. This function requires the Referral Customer’s API key.
136 137 138 139 140 141 142 143 |
# File 'lib/easypost/beta/referral.rb', line 136 def self.refund_by_amount(amount, api_key = nil) params = { refund_amount: amount, } response = EasyPost.make_request(:post, '/beta/referral_customers/refunds', api_key, params) # noinspection RubyMismatchedReturnType EasyPost::Util.convert_to_easypost_object(response, api_key) # TODO: Needs "object" or ID prefix to determine object class. end |
.refund_by_payment_log(payment_log_id, api_key = nil) ⇒ EasyPost::Beta::PaymentRefund
Refund a Referral Customer’s wallet for a specified payment log entry. Refund will be issued to the user’s original payment method. This function requires the Referral Customer’s API key.
150 151 152 153 154 155 156 157 |
# File 'lib/easypost/beta/referral.rb', line 150 def self.refund_by_payment_log(payment_log_id, api_key = nil) params = { payment_log_id: payment_log_id, } response = EasyPost.make_request(:post, '/beta/referral_customers/refunds', api_key, params) # noinspection RubyMismatchedReturnType EasyPost::Util.convert_to_easypost_object(response, api_key) # TODO: Needs "object" or ID prefix to determine object class. end |
.update_email(email, user_id, api_key = nil) ⇒ Object
Update a referral customer. This function requires the Partner User’s API key. DEPRECATED: Please use Referral in the main namespace instead.
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/easypost/beta/referral.rb', line 68 def self.update_email(email, user_id, api_key = nil) warn '[DEPRECATION] Please use `Referral.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 |