Class: SimplePin::Pin

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/simple_pin.rb

Defined Under Namespace

Classes: PinError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key = '', env = :test) ⇒ Pin

Create a new Pin instance

key: Your Pin secret key
env: The environment you want to use.


12
13
14
15
16
17
18
19
20
21
# File 'lib/simple_pin.rb', line 12

def initialize(key = '', env = :test)
  @key = key
  env = env.to_sym
  @auth = { username: @key, password: '' }
  @base_url = if env == :live
                'https://api.pin.net.au/1/'
              else
                'https://test-api.pin.net.au/1/'
              end
end

Instance Attribute Details

#authObject

Returns the value of attribute auth.



6
7
8
# File 'lib/simple_pin.rb', line 6

def auth
  @auth
end

#base_urlObject

Returns the value of attribute base_url.



6
7
8
# File 'lib/simple_pin.rb', line 6

def base_url
  @base_url
end

Instance Method Details

#create_card(options = {}) ⇒ Object

Creates a card given a hash of options pin.net.au/docs/api/cards returns: a card object



43
44
45
# File 'lib/simple_pin.rb', line 43

def create_card(options = {})
  build_response(make_request(:post, url: 'cards', options: options))
end

#create_charge(options = {}) ⇒ Object

Create a charge given charge details and a card, pin.net.au/docs/api/charges returns: a charge object



34
35
36
# File 'lib/simple_pin.rb', line 34

def create_charge(options = {})
  build_response(make_request(:post, url: 'charges', options: options))
end

#create_customer(options = {}) ⇒ Object

Create a customer given customer details and a card_token pin.net.au/docs/api/customers returns: a customer object



52
53
54
# File 'lib/simple_pin.rb', line 52

def create_customer(options = {})
  build_response(make_request(:post, url: 'customers', options: options))
end