Class: EasyPost::Beta::Referral

Inherits:
Resource show all
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

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.



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

.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.



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 user. 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

.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.



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