Class: Pin::Base
Overview
This class sets up a few things like the base URL and provides a few utility methods to be shared between classes.
Instance Method Summary collapse
-
#initialize(key = "", env = :live) ⇒ Base
constructor
Create a new Pin instance Args: key: Your Pin secret key env: The environment you want to use.
-
#key ⇒ Object
Provides access to your key if needed.
-
#uri ⇒ Object
Provides access to the base URL if needed.
Constructor Details
#initialize(key = "", env = :live) ⇒ Base
Create a new Pin instance Args:
key: Your Pin secret key
env: The environment you want to use. Leave blank for live and pass in :test for test
An error is raised if an invalid env is passed in.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pin_up/base.rb', line 13 def initialize(key = "", env = :live) @key = key env = env.to_sym @@auth = {username: key, password: ''} @@base_url = if env == :live "https://api.pin.net.au/1/" elsif env == :test "https://test-api.pin.net.au/1/" else raise "'env' option must be :live or :test. Leave blank for live payments" end end |
Instance Method Details
#key ⇒ Object
Provides access to your key if needed
28 29 30 |
# File 'lib/pin_up/base.rb', line 28 def key @key end |
#uri ⇒ Object
Provides access to the base URL if needed
34 35 36 |
# File 'lib/pin_up/base.rb', line 34 def uri @@base_url end |