seriline 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +21 -0
- data/README.md +90 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/seriline.rb +23 -0
- data/lib/seriline/client.rb +68 -0
- data/lib/seriline/config_product.rb +22 -0
- data/lib/seriline/endpoint.rb +21 -0
- data/lib/seriline/errors.rb +18 -0
- data/lib/seriline/order.rb +14 -0
- data/lib/seriline/request.rb +63 -0
- data/lib/seriline/response_data.rb +44 -0
- data/lib/seriline/responses/available_config_products_response.rb +22 -0
- data/lib/seriline/responses/config_product_single_order_response.rb +7 -0
- data/lib/seriline/responses/login_response.rb +19 -0
- data/lib/seriline/responses/order_info_response.rb +7 -0
- data/lib/seriline/session.rb +22 -0
- data/lib/seriline/version.rb +3 -0
- data/seriline.gemspec +36 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c594d722c243050ad034e3637907fdb19a17bceb
|
4
|
+
data.tar.gz: 2f08a08f3360645eac5ae52c82544b1526938d89
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: db3d664d2b0652f33e3af16d68d4bfd9c86c74a3cf36e1e05fbfcfa2ee3f2ac80453101b84d2439ce1799852a9acdb31428c8ae72c94d27da5858415c94487a1
|
7
|
+
data.tar.gz: 880e4fd68f94023a0090613c345e2724da8885ca643287104745363ccf5dd3ccff427b4a455c07fd79b5b60bcd42b7b2fa6c155ea7cb10b8509f547447bd2dcc
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
seriline (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
addressable (2.5.2)
|
10
|
+
public_suffix (>= 2.0.2, < 4.0)
|
11
|
+
crack (0.4.3)
|
12
|
+
safe_yaml (~> 1.0.0)
|
13
|
+
diff-lcs (1.3)
|
14
|
+
hashdiff (0.3.7)
|
15
|
+
public_suffix (3.0.1)
|
16
|
+
rake (10.4.2)
|
17
|
+
rspec (3.7.0)
|
18
|
+
rspec-core (~> 3.7.0)
|
19
|
+
rspec-expectations (~> 3.7.0)
|
20
|
+
rspec-mocks (~> 3.7.0)
|
21
|
+
rspec-core (3.7.0)
|
22
|
+
rspec-support (~> 3.7.0)
|
23
|
+
rspec-expectations (3.7.0)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.7.0)
|
26
|
+
rspec-mocks (3.7.0)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.7.0)
|
29
|
+
rspec-support (3.7.0)
|
30
|
+
safe_yaml (1.0.4)
|
31
|
+
webmock (3.2.0)
|
32
|
+
addressable (>= 2.3.6)
|
33
|
+
crack (>= 0.3.2)
|
34
|
+
hashdiff
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
ruby
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
bundler (~> 1.16)
|
41
|
+
rake (~> 10.0)
|
42
|
+
rspec (~> 3.0)
|
43
|
+
seriline!
|
44
|
+
webmock (~> 3.2)
|
45
|
+
|
46
|
+
BUNDLED WITH
|
47
|
+
1.16.0
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Emric
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# Seriline
|
2
|
+
Seriline provides an API for ordering their products. This gem provides a simple method
|
3
|
+
for connecting and using the API.
|
4
|
+
# Configuration
|
5
|
+
For any Seriline request you must first login.
|
6
|
+
A session will be active for 60 minutes and during that session you can
|
7
|
+
use the other parts of the API.
|
8
|
+
|
9
|
+
You can store details with a configuration block:
|
10
|
+
```ruby
|
11
|
+
# configure Seriline details
|
12
|
+
Seriline.configure do |config|
|
13
|
+
config.username = username
|
14
|
+
config.api_key = api_key
|
15
|
+
end
|
16
|
+
```
|
17
|
+
# Usage
|
18
|
+
All actions execute requests to the seriline API. This means something
|
19
|
+
could go wrong on the way. All returned data however; is returned as an
|
20
|
+
object with the `success?` method. If a request fails you can use that flag
|
21
|
+
along with `error_message` to troubleshoot eventual client problems.
|
22
|
+
## Authentication
|
23
|
+
To connect to the API either do it with block syntax:
|
24
|
+
```ruby
|
25
|
+
Seriline::Client.with_connection do |client|
|
26
|
+
# <- Your awesome code goes here
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
Or manually by instantiating `Seriline::Client`:
|
31
|
+
```ruby
|
32
|
+
client = Seriline::Client.new
|
33
|
+
client.login
|
34
|
+
# <- Your awesome code goes here
|
35
|
+
client.logout
|
36
|
+
```
|
37
|
+
|
38
|
+
Both are the same. Using block syntax you won't have to worry about logging in and out.
|
39
|
+
If you have not configured seriline with username and api key you can provide that to any
|
40
|
+
of those methods.
|
41
|
+
|
42
|
+
- [X] `GET api/Authentication/Login?username={username}&apiKey={apiKey}`
|
43
|
+
- [X] `GET api/Authentication/Logout?sessionKey={sessionKey}`
|
44
|
+
|
45
|
+
## Configproducts
|
46
|
+
A config product is a custom product which you can order.
|
47
|
+
|
48
|
+
You can list your available config products like so:
|
49
|
+
```ruby
|
50
|
+
Seriline::Client.with_connection do |client|
|
51
|
+
client.get_available_config_products
|
52
|
+
end
|
53
|
+
```
|
54
|
+
This returns a `AvailableConfigProductsResponse`. From that you can access the products with `AvailableConfigProductsResponse#products.`
|
55
|
+
|
56
|
+
When you have your product id you can proceed to do a single order.
|
57
|
+
```ruby
|
58
|
+
Seriline::Client.with_connection do |client|
|
59
|
+
client.order_config_product(my_product_id, data)
|
60
|
+
end
|
61
|
+
```
|
62
|
+
This will return a `ConfigProductSingleOrderResponse` object which amongst other
|
63
|
+
things contains `order_id`. This key can be used for looking up more information
|
64
|
+
about this specific order and should thus be kept.
|
65
|
+
|
66
|
+
- [X] `GET api/ConfigProduct/GetAvailable?sessionKey={sessionKey}`
|
67
|
+
- [ ] `GET api/ConfigProduct/GetConfigProductInfo?sessionKey={sessionKey}&productId={productId} `
|
68
|
+
- [X] `POST api/ConfigProduct/SingleOrder`
|
69
|
+
- [ ] `POST api/ConfigProduct/BatchOrder`
|
70
|
+
- [ ] `GET api/ConfigProduct/GetProductionData?sessionKey={sessionKey}&configProductId={configProductId}`
|
71
|
+
|
72
|
+
### Cards
|
73
|
+
- [ ] `GET api/Card/GetProducedCards?sessionKey={sessionKey}&fromDateTime={fromDateTime}&toDateTime={toDateTime}`
|
74
|
+
- [ ] `GET api/Card/GetNotProducedCards?sessionKey={sessionKey}`
|
75
|
+
- [ ] `GET api/Card/GetCardPersonPhoto?sessionKey={sessionKey}&cardId={cardId}`
|
76
|
+
- [ ] `GET api/Card/GetCardStatusChanges?sessionKey={sessionKey}&fromDateTime={fromDateTime}`
|
77
|
+
- [ ] `GET api/Card/ChangeCardStatus?sessionKey={sessionKey}&configProductId={configProductId}&action={action}`
|
78
|
+
|
79
|
+
### Accessories
|
80
|
+
- [ ] `GET api/Accessories/GetAvailable?sessionKey={sessionKey}`
|
81
|
+
|
82
|
+
### Orders
|
83
|
+
You can get information about an order by user `Seriline::Order`.
|
84
|
+
```ruby
|
85
|
+
Seriline::Client.with_connection do |client|
|
86
|
+
client.get_order_info(order_id)
|
87
|
+
end
|
88
|
+
```
|
89
|
+
|
90
|
+
- [X] `GET api/Order/GetOrderInfo?sessionKey={sessionKey}&orderId={orderId}`
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "seriline"
|
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/lib/seriline.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "seriline/version"
|
2
|
+
require "seriline/request"
|
3
|
+
require "seriline/session"
|
4
|
+
require "seriline/order"
|
5
|
+
require "seriline/errors"
|
6
|
+
require "seriline/endpoint"
|
7
|
+
require "seriline/config_product"
|
8
|
+
require "seriline/client"
|
9
|
+
|
10
|
+
module Seriline
|
11
|
+
class << self
|
12
|
+
attr_accessor :config
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.configure
|
16
|
+
self.config ||= Configuration.new
|
17
|
+
yield(config)
|
18
|
+
end
|
19
|
+
|
20
|
+
class Configuration
|
21
|
+
attr_accessor :username, :api_key
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require "seriline/responses/login_response"
|
2
|
+
require "seriline/session"
|
3
|
+
|
4
|
+
module Seriline
|
5
|
+
class Client
|
6
|
+
attr_reader :username,
|
7
|
+
:api_key,
|
8
|
+
:session
|
9
|
+
|
10
|
+
def initialize(username = Seriline.config.username, api_key = Seriline.config.api_key)
|
11
|
+
@username = username
|
12
|
+
@api_key = api_key
|
13
|
+
@session = Seriline::Session.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.with_connection(username = Seriline.config.username, api_key = Seriline.config.api_key)
|
17
|
+
client = Seriline::Client.new(username, api_key)
|
18
|
+
self.client_connection(client) { yield }
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.client_connection(client)
|
22
|
+
client.login
|
23
|
+
yield(client) if client.session.active?
|
24
|
+
ensure
|
25
|
+
client.logout
|
26
|
+
end
|
27
|
+
|
28
|
+
def login
|
29
|
+
return if @session.active?
|
30
|
+
Seriline::Request.get(
|
31
|
+
Seriline::Endpoint.login_path,
|
32
|
+
{ username: @username, apiKey: @api_key }
|
33
|
+
).tap(&store_session_info)
|
34
|
+
end
|
35
|
+
|
36
|
+
def logout
|
37
|
+
return unless @session.active?
|
38
|
+
Seriline::Request.get(
|
39
|
+
Seriline::Endpoint.logout_path,
|
40
|
+
{ sessionKey: @session.session_key }
|
41
|
+
).tap(&destroy_session_info)
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_available_config_products
|
45
|
+
ConfigProduct.get_available(@session)
|
46
|
+
end
|
47
|
+
|
48
|
+
def order_config_product(product_id, data)
|
49
|
+
ConfigProduct.order(@session, product_id, data)
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_order_info(order_id)
|
53
|
+
Order.get_order_info(session, order_id)
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def store_session_info
|
59
|
+
lambda { |response|
|
60
|
+
@session = Seriline::Session.new Seriline::LoginResponse.new(response)
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
def destroy_session_info
|
65
|
+
-> (_response) { @session = Seriline::Session.new }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "seriline/responses/config_product_single_order_response"
|
2
|
+
require "seriline/responses/available_config_products_response"
|
3
|
+
require "seriline/request"
|
4
|
+
|
5
|
+
module Seriline
|
6
|
+
class ConfigProduct
|
7
|
+
def self.get_available(session)
|
8
|
+
result = Request.get(Seriline::Endpoint.get_available_config_products_path,
|
9
|
+
{ sessionKey: session.session_key })
|
10
|
+
Seriline::AvailableConfigProductsResponse.new(result)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.order(session, product_id, data = {})
|
14
|
+
result = Request.post(Seriline::Endpoint.config_product_single_order_path,
|
15
|
+
{
|
16
|
+
sessionKey: session.session_key,
|
17
|
+
Specification: { ProductId: product_id }
|
18
|
+
}.merge(data))
|
19
|
+
Seriline::ConfigProductSingleOrderResponse.new(result)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "uri"
|
2
|
+
|
3
|
+
module Seriline
|
4
|
+
class Endpoint
|
5
|
+
BASE_URI = "https://api.webconnect.cloud/v2/api"
|
6
|
+
|
7
|
+
{
|
8
|
+
login: "/Authentication/Login",
|
9
|
+
logout: "/Authentication/Logout",
|
10
|
+
get_available_config_products: "/ConfigProduct/GetAvailable",
|
11
|
+
config_product_single_order: "/ConfigProduct/SingleOrder",
|
12
|
+
get_order_info: "/Order/GetOrderInfo"
|
13
|
+
}.each do |action, path|
|
14
|
+
define_singleton_method("#{action}_path") do |query = {}|
|
15
|
+
URI(BASE_URI + path).tap do |uri|
|
16
|
+
uri.query = URI.encode_www_form(query)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Seriline
|
2
|
+
class Error < StandardError; end
|
3
|
+
|
4
|
+
class RequestFailedError < Error
|
5
|
+
def initialize(net_http_error)
|
6
|
+
super build_message(net_http_error)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def build_message(net_http_error)
|
12
|
+
%(
|
13
|
+
Net::HTTP failed to execute request with the following status:
|
14
|
+
Status: #{net_http_error.code}
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "seriline/responses/order_info_response"
|
2
|
+
|
3
|
+
module Seriline
|
4
|
+
class Order
|
5
|
+
def self.get_order_info(session, order_id)
|
6
|
+
result = Request.get(Seriline::Endpoint.get_order_info_path,
|
7
|
+
{
|
8
|
+
sessionKey: session.session_key,
|
9
|
+
orderId: order_id
|
10
|
+
})
|
11
|
+
Seriline::OrderInfoResponse.new(result)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "net/https"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Seriline
|
6
|
+
class Request
|
7
|
+
class << self
|
8
|
+
def get(uri, body = {})
|
9
|
+
Request.new(uri).execute(body)
|
10
|
+
end
|
11
|
+
|
12
|
+
def post(uri, body = {})
|
13
|
+
Request.new(uri, method: "POST")
|
14
|
+
.execute(body)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(uri, method: "GET")
|
19
|
+
@method = method
|
20
|
+
@uri = URI(uri)
|
21
|
+
end
|
22
|
+
|
23
|
+
def execute(body = {})
|
24
|
+
response = http.request(request_object(body))
|
25
|
+
evaluate_response(response)
|
26
|
+
return parse_response(response)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def http
|
32
|
+
@http ||= Net::HTTP.new(@uri.host, @uri.port)
|
33
|
+
.tap do |http_instance|
|
34
|
+
http_instance.use_ssl = true
|
35
|
+
http_instance.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def evaluate_response(response)
|
40
|
+
response.value
|
41
|
+
rescue
|
42
|
+
raise Seriline::RequestFailedError.new(response)
|
43
|
+
end
|
44
|
+
|
45
|
+
def parse_response(response)
|
46
|
+
return {} if response.body.empty?
|
47
|
+
JSON.parse(response.body, {quirks_mode: true})
|
48
|
+
end
|
49
|
+
|
50
|
+
def request_object(body)
|
51
|
+
@request_object ||= case @method
|
52
|
+
when "GET"
|
53
|
+
@uri.query = URI.encode_www_form(body)
|
54
|
+
Net::HTTP::Get.new(@uri)
|
55
|
+
when "POST"
|
56
|
+
Net::HTTP::Post.new(@uri).tap do |req|
|
57
|
+
req.content_type = "application/json"
|
58
|
+
req.body = body.to_json
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
# This class represents a simple struct like object.
|
3
|
+
# - Permitted attributes must be defined with `attr_reader`
|
4
|
+
# - When initialized attribute keys will be snake cased.
|
5
|
+
# For example { CamelCase: "Hello world!" }
|
6
|
+
# would set the instance variable @camel_case
|
7
|
+
#
|
8
|
+
# Example:
|
9
|
+
#
|
10
|
+
# class PersonResponse < Seriline::ResponseData
|
11
|
+
# attr_reader :name, :email
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# PersonResponse.new({
|
15
|
+
# name: "Bob",
|
16
|
+
# email: "bob-the-builder@gmail.com",
|
17
|
+
# password: "secret"
|
18
|
+
# })
|
19
|
+
#
|
20
|
+
#=> #<PersonResponse:0x007fca321df778 @name="Bob", @email="bob-the-builder@gmail.com">
|
21
|
+
module Seriline
|
22
|
+
class ResponseData
|
23
|
+
def initialize(attributes = {})
|
24
|
+
attributes.each do |attribute, value|
|
25
|
+
reader_name = snake_case(attribute)
|
26
|
+
next unless respond_to? reader_name
|
27
|
+
instance_variable_set("@#{reader_name}", value)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def success?
|
32
|
+
success
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def snake_case(string)
|
38
|
+
string = string.to_s
|
39
|
+
scan = string.scan(/[A-Z]*[a-z]+/)
|
40
|
+
return string.downcase if scan.empty?
|
41
|
+
scan.map(&:downcase) * "_"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "seriline/response_data"
|
2
|
+
|
3
|
+
module Seriline
|
4
|
+
class AvailableConfigProductsResponse < Seriline::ResponseData
|
5
|
+
attr_reader :success, :error_message, :products
|
6
|
+
|
7
|
+
def initialize(attributes = {})
|
8
|
+
super(attributes)
|
9
|
+
serialize_products
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def serialize_products
|
15
|
+
@products = @products.map {|product_hash| AvailableConfigProductNode.new(product_hash) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class AvailableConfigProductNode < Seriline::ResponseData
|
20
|
+
attr_reader :product_id, :name, :short_description, :is_batch_product
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "seriline/response_data"
|
2
|
+
|
3
|
+
module Seriline
|
4
|
+
class LoginResponse < Seriline::ResponseData
|
5
|
+
attr_reader :success, :session_key, :error_message, :valid_to
|
6
|
+
|
7
|
+
def initialize(attributes)
|
8
|
+
super(attributes)
|
9
|
+
parse_valid_to
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def parse_valid_to
|
15
|
+
return if @valid_to.nil?
|
16
|
+
@valid_to = Time.parse(@valid_to.to_s)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "seriline/responses/login_response"
|
2
|
+
require "time"
|
3
|
+
|
4
|
+
module Seriline
|
5
|
+
class Session
|
6
|
+
attr_reader :login_response
|
7
|
+
|
8
|
+
def initialize(login_response = nil)
|
9
|
+
@login_response = login_response
|
10
|
+
end
|
11
|
+
|
12
|
+
def active?
|
13
|
+
@login_response &&
|
14
|
+
@login_response.success &&
|
15
|
+
@login_response.valid_to > Time.now
|
16
|
+
end
|
17
|
+
|
18
|
+
def session_key
|
19
|
+
@login_response && @login_response.session_key
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/seriline.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "seriline/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "seriline"
|
8
|
+
spec.version = Seriline::VERSION
|
9
|
+
spec.authors = ["Emric"]
|
10
|
+
spec.email = ["w.e.w@live.se"]
|
11
|
+
|
12
|
+
spec.summary = %q{A gem for integrating with the Serline API}
|
13
|
+
spec.homepage = "https://github.com/standout/seriline"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
"public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
+
spec.add_development_dependency "webmock", "~> 3.2"
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: seriline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Emric
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.2'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- w.e.w@live.se
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- lib/seriline.rb
|
87
|
+
- lib/seriline/client.rb
|
88
|
+
- lib/seriline/config_product.rb
|
89
|
+
- lib/seriline/endpoint.rb
|
90
|
+
- lib/seriline/errors.rb
|
91
|
+
- lib/seriline/order.rb
|
92
|
+
- lib/seriline/request.rb
|
93
|
+
- lib/seriline/response_data.rb
|
94
|
+
- lib/seriline/responses/available_config_products_response.rb
|
95
|
+
- lib/seriline/responses/config_product_single_order_response.rb
|
96
|
+
- lib/seriline/responses/login_response.rb
|
97
|
+
- lib/seriline/responses/order_info_response.rb
|
98
|
+
- lib/seriline/session.rb
|
99
|
+
- lib/seriline/version.rb
|
100
|
+
- seriline.gemspec
|
101
|
+
homepage: https://github.com/standout/seriline
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata:
|
105
|
+
allowed_push_host: https://rubygems.org
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.4.5.1
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: A gem for integrating with the Serline API
|
126
|
+
test_files: []
|