Class: Privateer::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/privateer/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Connection

Returns a new instance of Connection.

Raises:

  • (ArgumentError)


2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/privateer/connection.rb', line 2

def initialize(options = {})
  raise ArgumentError, 'store_name is required' if options[:store_name].nil?
  raise ArgumentError, 'api_key is required' if options[:api_key].nil?
  raise ArgumentError, 'password is required' if options[:password].nil?

  @store_name = options[:store_name]
  @api_key = options[:api_key]
  @password = options[: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