agendrix-nethris 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +33 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/test +33 -0
- data/lib/agendrix/nethris.rb +20 -0
- data/lib/agendrix/nethris/client.rb +38 -0
- data/lib/agendrix/nethris/collection_proxy.rb +58 -0
- data/lib/agendrix/nethris/entities/address.rb +14 -0
- data/lib/agendrix/nethris/entities/employee.rb +62 -0
- data/lib/agendrix/nethris/entities/phone_number.rb +19 -0
- data/lib/agendrix/nethris/entity.rb +43 -0
- data/lib/agendrix/nethris/errors.rb +27 -0
- data/lib/agendrix/nethris/request.rb +103 -0
- data/lib/agendrix/nethris/services/employee_service.rb +43 -0
- data/lib/agendrix/nethris/services/session_service.rb +52 -0
- data/lib/agendrix/nethris/version.rb +5 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5075e1abf276e20515d677fe5af327a749797126006faf1bba2b72ec5c4b59a0
|
4
|
+
data.tar.gz: cae6fd79334a3da19693a1deb173aaaa585506e5fa626f77eeaf68b429206cb3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 189ee43aff5a8ebca5e874cf984d4aadac51fc5888c54053fcbcbc5b6d24d1f0af9a2eb6bbcb49c87ab1a07b500dd4d77570f69c946a457d8470b83ccbd918c4
|
7
|
+
data.tar.gz: 404928eba5b40ec171845043f3221c2398417d4d439ddf35fa169c6ba8167a2723bb08e0f74b529d89de3ce1c11fbbcd0fd61ab26925a219ebc4b0a051f71bee
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Agendrix::Nethris
|
2
|
+
|
3
|
+
To experiment with that code, run `bin/test`.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'agendrix-nethris'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install agendrix-nethris
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
This gem is used to get Nethris employee data. You can get `empl_id`, `empl_number`, `first_name`, `last_name`, `date_of_birth`, `email_work`,`address_street`, `phone_type`, `area_code`, `phone_number`, `ext_number`, `empl_disp_status`
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/charlesvallieres/agendrix-nethris.
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "agendrix/nethris"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/bin/test
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
|
5
|
+
require "dotenv"
|
6
|
+
Dotenv.load
|
7
|
+
|
8
|
+
require "agendrix/nethris"
|
9
|
+
|
10
|
+
Agendrix::Nethris.app_id = ENV["NETHRIS_APP_ID"]
|
11
|
+
Agendrix::Nethris.demo = true
|
12
|
+
|
13
|
+
nethris = Agendrix::Nethris::Client.new(
|
14
|
+
vendor: Agendrix::Nethris::Client::Vendor::NETHRIS,
|
15
|
+
user_code: ENV["NETHRIS_USER_CODE"],
|
16
|
+
password: ENV["NETHRIS_USER_PASSWORD"],
|
17
|
+
business_code: ENV["NETHRIS_DEMO_BUSINESS_CODE"]
|
18
|
+
)
|
19
|
+
|
20
|
+
puts "---ALL---"
|
21
|
+
nethris.employees.all(fields: ["EMPL_ID"]).each do |employee|
|
22
|
+
# employee = nethris.employees.get(employee.empl_id)
|
23
|
+
puts employee.inspect
|
24
|
+
end
|
25
|
+
|
26
|
+
puts "---GET---"
|
27
|
+
employee = nethris.employees.get("zfAvL3OsQos=") # Anne Verveine
|
28
|
+
puts employee.inspect
|
29
|
+
puts employee.full_name
|
30
|
+
|
31
|
+
puts "---LOG_OUT---"
|
32
|
+
nethris.session.log_out
|
33
|
+
puts "SUCCESS"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "active_support/all"
|
2
|
+
|
3
|
+
require "agendrix/nethris/version"
|
4
|
+
require "agendrix/nethris/client"
|
5
|
+
require "agendrix/nethris/errors"
|
6
|
+
require "agendrix/nethris/request"
|
7
|
+
require "agendrix/nethris/entity"
|
8
|
+
require "agendrix/nethris/entities/employee"
|
9
|
+
require "agendrix/nethris/entities/phone_number"
|
10
|
+
require "agendrix/nethris/entities/address"
|
11
|
+
require "agendrix/nethris/collection_proxy"
|
12
|
+
require "agendrix/nethris/services/session_service"
|
13
|
+
require "agendrix/nethris/services/employee_service"
|
14
|
+
|
15
|
+
module Agendrix
|
16
|
+
module Nethris
|
17
|
+
mattr_accessor(:app_id)
|
18
|
+
mattr_accessor(:demo)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Agendrix
|
2
|
+
module Nethris
|
3
|
+
class Client
|
4
|
+
module Vendor
|
5
|
+
NETHRIS = :nethris
|
6
|
+
EMPLOYER_D = :employer_d
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader(
|
10
|
+
:vendor,
|
11
|
+
:session
|
12
|
+
)
|
13
|
+
|
14
|
+
def initialize(vendor:, session_id: nil, user_code: nil, password: nil, business_code: nil)
|
15
|
+
unless vendor.in?([Vendor::NETHRIS, Vendor::EMPLOYER_D])
|
16
|
+
raise TypeError, "Vendor must be one of :#{Vendor::NETHRIS} or :#{Vendor::EMPLOYER_D}"
|
17
|
+
end
|
18
|
+
|
19
|
+
@vendor = vendor
|
20
|
+
@session = Services::SessionService.new(
|
21
|
+
vendor: @vendor,
|
22
|
+
id: session_id,
|
23
|
+
business_code: business_code,
|
24
|
+
user_code: user_code,
|
25
|
+
password: password
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def employees
|
30
|
+
@employees ||= Services::EmployeeService.new(self)
|
31
|
+
end
|
32
|
+
|
33
|
+
def send_request(**args)
|
34
|
+
Request.new(@vendor, @session.id).execute(**args)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Agendrix
|
2
|
+
module Nethris
|
3
|
+
class CollectionProxy
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
def initialize(client, entity_class, options = {})
|
7
|
+
@client = client
|
8
|
+
@entity_class = entity_class
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def each(&block)
|
13
|
+
has_next_page = false
|
14
|
+
current_page = 0
|
15
|
+
|
16
|
+
loop do
|
17
|
+
current_page += 1
|
18
|
+
body = fetch(page: current_page)
|
19
|
+
|
20
|
+
current_page = body["CurrentPage"].to_i
|
21
|
+
ipp = body["RecordsPerPage"].to_i
|
22
|
+
total_count = body["TotalCount"].to_i
|
23
|
+
has_next_page = current_page * ipp < total_count
|
24
|
+
|
25
|
+
body["data"].each do |entity_hash|
|
26
|
+
yield(@entity_class.new(@client, entity_hash))
|
27
|
+
end
|
28
|
+
|
29
|
+
break if !has_next_page
|
30
|
+
end
|
31
|
+
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
def [](target_index)
|
36
|
+
self.each_with_index do |item, index|
|
37
|
+
return item if index == target_index
|
38
|
+
end
|
39
|
+
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def fetch(page: 1)
|
46
|
+
parameters = @options.merge(
|
47
|
+
PageNumber: page
|
48
|
+
)
|
49
|
+
|
50
|
+
@client.send_request(
|
51
|
+
type: Request::Type::LIST,
|
52
|
+
entity_type: @entity_class.type,
|
53
|
+
parameters: parameters
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Agendrix
|
2
|
+
module Nethris
|
3
|
+
class Employee < Entity
|
4
|
+
def self.type
|
5
|
+
Request::EntityType::EMPLOYEE
|
6
|
+
end
|
7
|
+
|
8
|
+
module EmplStatus
|
9
|
+
ACTIVE = 1.freeze
|
10
|
+
INACTIVE = 2.freeze
|
11
|
+
TERMINATED = 3.freeze
|
12
|
+
ON_VACATION = 4.freeze
|
13
|
+
LEAVE_OF_ABSENCE = 5.freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
FIELDS = [
|
17
|
+
"CO_NUMBER",
|
18
|
+
"EMPL_ID",
|
19
|
+
"EMPL_NUMBER",
|
20
|
+
"FIRST_NAME",
|
21
|
+
"LAST_NAME",
|
22
|
+
"GENDER_CODE",
|
23
|
+
"EMAIL_WORK",
|
24
|
+
"HIRE_DATE",
|
25
|
+
"DATE_OF_BIRTH",
|
26
|
+
"EMPLOYEE_RATE",
|
27
|
+
"DEPARTURE_DATE",
|
28
|
+
"DIVISION_NO",
|
29
|
+
"SERVICE_NO",
|
30
|
+
"DEPARTM_NO",
|
31
|
+
"SUBDEPARTM_NO",
|
32
|
+
"EMPL_DISP_STATUS"
|
33
|
+
].freeze
|
34
|
+
|
35
|
+
attr_reader(
|
36
|
+
:addresses,
|
37
|
+
:phones
|
38
|
+
)
|
39
|
+
|
40
|
+
def initialize(client, data)
|
41
|
+
attributes = {}
|
42
|
+
|
43
|
+
FIELDS.each do |field|
|
44
|
+
attributes[field] = data&.[](field)
|
45
|
+
end
|
46
|
+
|
47
|
+
attributes["HIRE_DATE"] = Date.parse(attributes["HIRE_DATE"]) if attributes["HIRE_DATE"]
|
48
|
+
attributes["DEPARTURE_DATE"] = Date.parse(attributes["DEPARTURE_DATE"]) if attributes["DEPARTURE_DATE"]
|
49
|
+
attributes["DATE_OF_BIRTH"] = Date.parse(attributes["DATE_OF_BIRTH"]) if attributes["DATE_OF_BIRTH"]
|
50
|
+
|
51
|
+
super(client, attributes)
|
52
|
+
|
53
|
+
@addresses = parse_relation(Address, data["Addresses"])
|
54
|
+
@phones = parse_relation(PhoneNumber, data["Phones"])
|
55
|
+
end
|
56
|
+
|
57
|
+
def full_name
|
58
|
+
"#{first_name} #{last_name}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Agendrix
|
2
|
+
module Nethris
|
3
|
+
class PhoneNumber < Entity
|
4
|
+
FIELDS = [
|
5
|
+
"AREA_CODE",
|
6
|
+
"PHONE_TYPE",
|
7
|
+
"PHONE_NUMBER",
|
8
|
+
"EXT_NUMBER"
|
9
|
+
].freeze
|
10
|
+
|
11
|
+
module Type
|
12
|
+
MOBILE = "C".freeze
|
13
|
+
HOME = "R".freeze
|
14
|
+
SECONDARY = "S".freeze
|
15
|
+
WORK = "T".freeze
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Agendrix
|
2
|
+
module Nethris
|
3
|
+
class Entity
|
4
|
+
def initialize(client, attributes)
|
5
|
+
@client = client
|
6
|
+
@attributes = attributes
|
7
|
+
end
|
8
|
+
|
9
|
+
def inspect
|
10
|
+
variables = self.instance_variables - [:"@client"]
|
11
|
+
variables.map! { |v| "#{v}=#{self.instance_eval(v.to_s)}" }
|
12
|
+
"#<#{self.class} #{variables.join(', ')}>"
|
13
|
+
end
|
14
|
+
|
15
|
+
def method_missing(method_name)
|
16
|
+
method_name_s = method_name.to_s
|
17
|
+
|
18
|
+
if @attributes.key?(method_name_s.upcase)
|
19
|
+
@attributes[method_name_s.upcase]
|
20
|
+
elsif @attributes.key?(method_name_s)
|
21
|
+
@attributes[method_name_s]
|
22
|
+
else
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def respond_to_missing?(method_name, include_private = false)
|
28
|
+
method_name_s = method_name.to_s
|
29
|
+
@attributes.key?(method_name_s) || @attributes.key?(method_name_s.upcase) || super
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def parse_relation(klass, data)
|
35
|
+
return [] if data.blank?
|
36
|
+
|
37
|
+
data["childData"].map do |child_data|
|
38
|
+
klass.new(@client, child_data)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Agendrix
|
2
|
+
module Nethris
|
3
|
+
class NethrisError < StandardError
|
4
|
+
attr_reader(
|
5
|
+
:broken_rules
|
6
|
+
)
|
7
|
+
|
8
|
+
def initialize(message, broken_rules = [])
|
9
|
+
@broken_rules = broken_rules
|
10
|
+
message += " (" + @broken_rules.first["Text"] + ")" if message && @broken_rules.try(:first)
|
11
|
+
super(message)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Raised when the session_id you provided is incorrect or not authorized to access certain type of data.
|
16
|
+
class AuthenticationError < NethrisError
|
17
|
+
end
|
18
|
+
|
19
|
+
# Raised when we experience a socket read timeout
|
20
|
+
class ServiceUnavailableError < NethrisError
|
21
|
+
end
|
22
|
+
|
23
|
+
# Raised when the request has bad syntax
|
24
|
+
class BadRequestError < NethrisError
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require "uri"
|
2
|
+
require "net/https"
|
3
|
+
|
4
|
+
module Agendrix
|
5
|
+
module Nethris
|
6
|
+
class Request
|
7
|
+
module Type
|
8
|
+
LOG_IN = "logIn".freeze
|
9
|
+
LOG_OUT = "logOut".freeze
|
10
|
+
LIST = "getList".freeze
|
11
|
+
UPDATE = "updateItem".freeze
|
12
|
+
GET = "getItem".freeze
|
13
|
+
UPLOAD_FILE = "putFile".freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
module EntityType
|
17
|
+
EMPLOYEE = "employee".freeze
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(vendor, session_id = nil)
|
21
|
+
raise TypeError, "vendor can't be nil" if vendor.nil?
|
22
|
+
|
23
|
+
@vendor = vendor
|
24
|
+
@session_id = session_id
|
25
|
+
end
|
26
|
+
|
27
|
+
def execute(type:, entity_type: nil, id: nil, parameters: nil)
|
28
|
+
body = generate_body(type: type, entity_type: entity_type, id: id, parameters: parameters)
|
29
|
+
request = generate_request(body)
|
30
|
+
response = client.request(request)
|
31
|
+
parsed_body = parse_body(response.body)
|
32
|
+
raise_errors_on_failure(parsed_body)
|
33
|
+
parse_data(parsed_body)
|
34
|
+
rescue Timeout::Error
|
35
|
+
raise ServiceUnavailableError, "Service Unavailable [request timed out]"
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
def endpoints
|
41
|
+
if Agendrix::Nethris.demo
|
42
|
+
{
|
43
|
+
Client::Vendor::NETHRIS => "https://demo.nethris.com/CSPaySuiteServices/wsWebSuiteService.svc/V.1.00/ExecuteRequest",
|
44
|
+
Client::Vendor::EMPLOYER_D => "https://demo.employeurd.com/CSPaySuiteServices/wsWebSuiteService.svc/V.1.00/ExecuteRequest"
|
45
|
+
}
|
46
|
+
else
|
47
|
+
{
|
48
|
+
Client::Vendor::NETHRIS => "https://clients.nethris.com/CSPaySuiteServices/wsWebSuiteService.svc/V.1.00/ExecuteRequest",
|
49
|
+
Client::Vendor::EMPLOYER_D => "https://employeurd.com/CSPaySuiteServices/wsWebSuiteService.svc/V.1.00/ExecuteRequest"
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def endpoint_uri
|
55
|
+
@_endpoint_uri ||= URI.parse(endpoints[@vendor])
|
56
|
+
end
|
57
|
+
|
58
|
+
def client
|
59
|
+
Net::HTTP.new(endpoint_uri.host, endpoint_uri.port).tap do |net|
|
60
|
+
if endpoint_uri.is_a?(URI::HTTPS)
|
61
|
+
net.use_ssl = true
|
62
|
+
net.verify_mode = OpenSSL::SSL::VERIFY_NONE # VERIFY_PEER
|
63
|
+
# net.ca_file = File.join(File.dirname(__FILE__), '../data/cacert.pem')
|
64
|
+
end
|
65
|
+
|
66
|
+
net.read_timeout = 90
|
67
|
+
net.open_timeout = 30
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def generate_request(body)
|
72
|
+
Net::HTTP::Post.new(endpoint_uri.to_s).tap do |request|
|
73
|
+
request.body = body.to_json
|
74
|
+
request["Content-Type"] = "application/json"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def generate_body(type:, entity_type:, id: nil, parameters: {})
|
79
|
+
{
|
80
|
+
SessionId: @session_id,
|
81
|
+
Type: type || "",
|
82
|
+
Entity: entity_type || "",
|
83
|
+
Id: id || "",
|
84
|
+
Parameters: parameters.to_json
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
def parse_body(body)
|
89
|
+
JSON.parse(body)
|
90
|
+
end
|
91
|
+
|
92
|
+
def raise_errors_on_failure(body)
|
93
|
+
if body["ReturnCode"].to_i == -1
|
94
|
+
raise BadRequestError.new("Bad request", body["BrokenRules"])
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def parse_data(body)
|
99
|
+
JSON.parse(body["ReturnData"])
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Agendrix
|
2
|
+
module Nethris
|
3
|
+
module Services
|
4
|
+
class EmployeeService
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def all(options = {})
|
10
|
+
parameters = options.merge(
|
11
|
+
OutputFields: options.fetch(:fields, all_fields)
|
12
|
+
)
|
13
|
+
|
14
|
+
CollectionProxy.new(@client, Nethris::Employee, parameters)
|
15
|
+
end
|
16
|
+
|
17
|
+
def get(id, options = {})
|
18
|
+
parameters = options.merge(
|
19
|
+
fields: options.fetch(:fields, all_fields)
|
20
|
+
)
|
21
|
+
|
22
|
+
data = @client.send_request(
|
23
|
+
type: Request::Type::GET,
|
24
|
+
entity_type: Nethris::Employee.type,
|
25
|
+
id: id,
|
26
|
+
parameters: parameters
|
27
|
+
)
|
28
|
+
|
29
|
+
data = data["Employee"]["data"][0]
|
30
|
+
data["EMPL_ID"] = id # Manually set id because API doesn't return it
|
31
|
+
|
32
|
+
Nethris::Employee.new(@client, data)
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
def all_fields
|
38
|
+
Nethris::Employee::FIELDS + Nethris::Address::FIELDS + Nethris::PhoneNumber::FIELDS
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Agendrix
|
2
|
+
module Nethris
|
3
|
+
module Services
|
4
|
+
class SessionService
|
5
|
+
attr_reader(
|
6
|
+
:id
|
7
|
+
)
|
8
|
+
|
9
|
+
def initialize(vendor:, id: nil, user_code: nil, password: nil, business_code: nil)
|
10
|
+
@vendor = vendor
|
11
|
+
|
12
|
+
if id.present?
|
13
|
+
@id = id
|
14
|
+
else
|
15
|
+
login(user_code: user_code, password: password, business_code: business_code)
|
16
|
+
end
|
17
|
+
|
18
|
+
raise AuthenticationError.new("Missing authentification credentials") if @id.blank?
|
19
|
+
end
|
20
|
+
|
21
|
+
def log_in(user_code:, password:, business_code:)
|
22
|
+
raise AuthenticationError.new("Already logged in") if @id.present?
|
23
|
+
|
24
|
+
data = Request.new(@vendor).execute(
|
25
|
+
type: Request::Type::LOG_IN,
|
26
|
+
parameters: {
|
27
|
+
APPID: Nethris.app_id,
|
28
|
+
businessCode: business_code,
|
29
|
+
userCode: user_code,
|
30
|
+
userPassword: password,
|
31
|
+
language: "en-US"
|
32
|
+
}
|
33
|
+
)
|
34
|
+
|
35
|
+
@id = data["sessionId"]
|
36
|
+
end
|
37
|
+
|
38
|
+
alias login log_in
|
39
|
+
|
40
|
+
def log_out
|
41
|
+
return unless @id
|
42
|
+
|
43
|
+
Request.new(@vendor, @id).execute(
|
44
|
+
type: Request::Type::LOG_OUT
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
alias logout log_out
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: agendrix-nethris
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.24
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Charles Vallières
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-12-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.15'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.15'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: dotenv
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- charles@agendrix.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- README.md
|
91
|
+
- bin/console
|
92
|
+
- bin/setup
|
93
|
+
- bin/test
|
94
|
+
- lib/agendrix/nethris.rb
|
95
|
+
- lib/agendrix/nethris/client.rb
|
96
|
+
- lib/agendrix/nethris/collection_proxy.rb
|
97
|
+
- lib/agendrix/nethris/entities/address.rb
|
98
|
+
- lib/agendrix/nethris/entities/employee.rb
|
99
|
+
- lib/agendrix/nethris/entities/phone_number.rb
|
100
|
+
- lib/agendrix/nethris/entity.rb
|
101
|
+
- lib/agendrix/nethris/errors.rb
|
102
|
+
- lib/agendrix/nethris/request.rb
|
103
|
+
- lib/agendrix/nethris/services/employee_service.rb
|
104
|
+
- lib/agendrix/nethris/services/session_service.rb
|
105
|
+
- lib/agendrix/nethris/version.rb
|
106
|
+
homepage:
|
107
|
+
licenses: []
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.7.7
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Ruby SDK for the Nethris API
|
129
|
+
test_files: []
|