Class: Privateer::Connection
- Inherits:
-
Object
- Object
- Privateer::Connection
- Defined in:
- lib/privateer/connection.rb
Instance Method Summary collapse
- #delete(target, params = {}) ⇒ Object
- #get(target, params = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #post(target, params = {}) ⇒ Object
- #put(target, params = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Connection
Returns a new instance of Connection.
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/privateer/connection.rb', line 2 def initialize( = {}) raise ArgumentError, 'store_name is required' if [:store_name].nil? raise ArgumentError, 'api_key is required' if [:api_key].nil? raise ArgumentError, 'password is required' if [:password].nil? @store_name = [:store_name] @api_key = [:api_key] @password = [:password] @store_url = "https://#{@api_key}:#{@password}@#{@store_name}.myshopify.com/admin/" @connection = Faraday.new(url: @store_url) end |
Instance Method Details
#delete(target, params = {}) ⇒ Object
28 29 30 |
# File 'lib/privateer/connection.rb', line 28 def delete(target, params = {}) call(:delete, target, params) end |
#get(target, params = {}) ⇒ Object
16 17 18 |
# File 'lib/privateer/connection.rb', line 16 def get(target, params = {}) call(:get, target, params) end |
#post(target, params = {}) ⇒ Object
20 21 22 |
# File 'lib/privateer/connection.rb', line 20 def post(target, params = {}) call(:post, target, params) end |
#put(target, params = {}) ⇒ Object
24 25 26 |
# File 'lib/privateer/connection.rb', line 24 def put(target, params = {}) call(:put, target, params) end |