Class: Spinacz::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/spinacz/client.rb

Constant Summary collapse

URL =
'https://spinacz.pl'
TEST_URL =
'https://test.spinacz.pl'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials = {}) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
14
15
16
# File 'lib/spinacz/client.rb', line 8

def initialize(credentials = {})
  @email = credentials[:email] || ENV['SPINACZ_EMAIL']
  @email = @email.strip if @email
  @password = credentials[:password] || ENV['SPINACZ_PASSWORD']
  @password = @password.strip if @password
  @token = credentials[:token] || ENV['SPINACZ_TOKEN']
  @token = @token.strip if @token
  @test = credentials[:test]
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



3
4
5
# File 'lib/spinacz/client.rb', line 3

def email
  @email
end

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'lib/spinacz/client.rb', line 3

def password
  @password
end

#testObject

Returns the value of attribute test.



3
4
5
# File 'lib/spinacz/client.rb', line 3

def test
  @test
end

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/spinacz/client.rb', line 3

def token
  @token
end

Instance Method Details

#add_package_DHL(package = {}) ⇒ Object



22
23
24
25
# File 'lib/spinacz/client.rb', line 22

def add_package_DHL(package = {})
  check_credentials
  call_api(:post, 'addPackageDHL', package)
end

#add_package_DPD(package = {}) ⇒ Object



27
28
29
30
# File 'lib/spinacz/client.rb', line 27

def add_package_DPD(package = {})
  check_credentials
  call_api(:post, 'addPackageDPD', package)
end

#add_package_FEDEX(package = {}) ⇒ Object



32
33
34
35
# File 'lib/spinacz/client.rb', line 32

def add_package_FEDEX(package = {})
  check_credentials
  call_api(:post, 'addPackageFEDEX', package)
end

#add_package_GLS(package = {}) ⇒ Object



37
38
39
40
# File 'lib/spinacz/client.rb', line 37

def add_package_GLS(package = {})
  check_credentials
  call_api(:post, 'addPackageGLS', package)
end

#add_package_INPOST(package = {}) ⇒ Object



42
43
44
45
# File 'lib/spinacz/client.rb', line 42

def add_package_INPOST(package = {})
  check_credentials
  call_api(:post, 'addPackageINPOST', package)
end

#add_package_KEX(package = {}) ⇒ Object



47
48
49
50
# File 'lib/spinacz/client.rb', line 47

def add_package_KEX(package = {})
  check_credentials
  call_api(:post, 'addPackageKEX', package)
end

#add_package_POCZTA(package = {}) ⇒ Object



52
53
54
55
# File 'lib/spinacz/client.rb', line 52

def add_package_POCZTA(package = {})
  check_credentials
  call_api(:post, 'addPackagePOCZTA', package)
end

#add_package_UPS(package = {}) ⇒ Object



57
58
59
60
# File 'lib/spinacz/client.rb', line 57

def add_package_UPS(package = {})
  check_credentials
  call_api(:post, 'addPackageUPS', package)
end

#cancel(query = {}) ⇒ Object



62
63
64
65
# File 'lib/spinacz/client.rb', line 62

def cancel(query = {})
  check_credentials
  call_api(:get, 'cancel', query)
end

#get_packages_templatesObject



67
68
69
70
# File 'lib/spinacz/client.rb', line 67

def get_packages_templates
  check_credentials
  call_api(:get, 'getPackagesTemplates')
end

#get_paczkomaty(query = {}) ⇒ Object



72
73
74
# File 'lib/spinacz/client.rb', line 72

def get_paczkomaty(query = {})
  call_api(:get, 'getPaczkomaty', query)
end

#get_placowki(query = {}) ⇒ Object



76
77
78
# File 'lib/spinacz/client.rb', line 76

def get_placowki(query = {})
  call_api(:get, 'getPlacowki', query)
end

#get_send_pointsObject



80
81
82
83
# File 'lib/spinacz/client.rb', line 80

def get_send_points
  check_credentials
  call_api(:get, 'getSendPoints')
end

#loginObject



18
19
20
# File 'lib/spinacz/client.rb', line 18

def 
  check_credentials
end

#pickup(query = {}) ⇒ Object



85
86
87
88
# File 'lib/spinacz/client.rb', line 85

def pickup(query = {})
  check_credentials
  call_api(:get, 'pickup', query)
end