Class: EasyPost::PaymentMethod

Inherits:
Resource show all
Defined in:
lib/easypost/payment_method.rb

Overview

PaymentMethod objects represent a payment method of a user.

Instance Attribute Summary

Attributes inherited from EasyPostObject

#api_key, #name, #parent, #unsaved_values

Class Method Summary collapse

Methods inherited from Resource

class_name, create, #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

.all(api_key = nil) ⇒ Object

Retrieve all payment methods.



6
7
8
9
10
11
12
13
14
# File 'lib/easypost/payment_method.rb', line 6

def self.all(api_key = nil)
  response = EasyPost.make_request(:get, url, api_key)

  if response['id'].nil?
    raise EasyPost::Error.new('Billing has not been setup for this user. Please add a payment method.')
  end

  EasyPost::Util.convert_to_easypost_object(response, api_key)
end