This repository was archived by the owner on Feb 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathexample.rb
More file actions
51 lines (45 loc) · 1.3 KB
/
example.rb
File metadata and controls
51 lines (45 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require './lib/vend'
require 'log4r'
STORE = ARGV[0]
USERNAME = ARGV[1]
PASSWORD = ARGV[2]
unless STORE && USERNAME && PASSWORD
$stderr.puts "Usage: example.rb store username password"
exit 1
end
client = Vend::Client.new(STORE, USERNAME, PASSWORD)
logger = Log4r::Logger.new 'vend'
logger.outputters = Log4r::Outputter.stdout
client.http_client.logger = client.logger = logger
# puts client.request('products', method: :put, body: '{"foo":"bar"}')
# puts "###### Products ######"
# client.Product.all.each do |product|
# puts product.name
# end
#
# puts "###### Customers ######"
# client.Customer.all.each do |customer|
# puts "#{customer.name} (#{customer.customer_code})"
# end
#
# puts "###### Creating a Customer ######"
# response = client.request('customers', method: :post, body: '{"customer_code":"foo"}')
# puts response
#
# puts "###### Finding a Customer by name ######"
# response = client.Customer.find_by_name('Foo')
# puts response.inspect
#
# puts "###### Finding a Customer by email ######"
# response = client.Customer.find_by_email('foo@example.com')
# puts response.inspect
#
# puts "###### Outlets ######"
# client.Outlet.all.each do |outlet|
# puts outlet.name
# end
#
# puts "###### Payment Types ######"
# client.PaymentType.all.each do |payment_type|
# puts payment_type.name
# end