xolphin-api 1.5.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +13 -12
- data/.rspec +2 -2
- data/.rubocop.yml +28 -28
- data/.travis.yml +5 -5
- data/CHANGELOG.md +19 -0
- data/Gemfile +6 -6
- data/LICENSE.txt +21 -21
- data/README.md +169 -169
- data/Rakefile +12 -12
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/examples/_credentials.rb +9 -8
- data/examples/certificate_cancel.rb +6 -6
- data/examples/certificate_reissue.rb +23 -25
- data/examples/certificate_renew.rb +22 -22
- data/examples/get_notes.rb +9 -9
- data/examples/invoices_get.rb +7 -0
- data/examples/request_create.rb +40 -0
- data/examples/request_create_ee.rb +29 -29
- data/examples/request_get_id.rb +6 -0
- data/examples/request_validation_call.rb +6 -5
- data/examples/requests_get.rb +8 -7
- data/examples/send_csa_email.rb +5 -5
- data/examples/send_note.rb +6 -6
- data/lib/xolphin/api/certificate_requests/certificate_reissue.rb +54 -47
- data/lib/xolphin/api/certificate_requests/certificate_renew.rb +58 -51
- data/lib/xolphin/api/certificate_requests/create_certificate_request.rb +59 -52
- data/lib/xolphin/api/certificate_requests/create_ee_request.rb +28 -33
- data/lib/xolphin/api/client.rb +25 -21
- data/lib/xolphin/api/dcv_type.rb +9 -9
- data/lib/xolphin/api/endpoint/certificate.rb +59 -59
- data/lib/xolphin/api/endpoint/invoice.rb +40 -0
- data/lib/xolphin/api/endpoint/request.rb +116 -86
- data/lib/xolphin/api/endpoint/support.rb +47 -47
- data/lib/xolphin/api/format_type.rb +12 -12
- data/lib/xolphin/api/http.rb +70 -67
- data/lib/xolphin/api/invoice_format_type.rb +8 -0
- data/lib/xolphin/api/product_type.rb +9 -9
- data/lib/xolphin/api/responses/base.rb +43 -43
- data/lib/xolphin/api/responses/certificate.rb +53 -53
- data/lib/xolphin/api/responses/certificates.rb +25 -25
- data/lib/xolphin/api/responses/csr_data.rb +43 -43
- data/lib/xolphin/api/responses/invoice.rb +57 -0
- data/lib/xolphin/api/responses/invoices.rb +25 -0
- data/lib/xolphin/api/responses/note.rb +45 -37
- data/lib/xolphin/api/responses/notes.rb +23 -24
- data/lib/xolphin/api/responses/product.rb +53 -53
- data/lib/xolphin/api/responses/product_price.rb +27 -27
- data/lib/xolphin/api/responses/products.rb +25 -25
- data/lib/xolphin/api/responses/request.rb +142 -119
- data/lib/xolphin/api/responses/request_ee.rb +29 -29
- data/lib/xolphin/api/responses/request_validation.rb +37 -37
- data/lib/xolphin/api/responses/request_validation_domain.rb +51 -35
- data/lib/xolphin/api/responses/requests.rb +25 -25
- data/lib/xolphin/api/responses/validation_call.rb +23 -0
- data/lib/xolphin/api/responses/validation_calls.rb +25 -0
- data/lib/xolphin/api/version.rb +5 -5
- data/lib/xolphin/api.rb +38 -32
- data/xolphin-api.gemspec +25 -26
- metadata +19 -9
- data/xolphin-api-0.1.0.gem +0 -0
data/lib/xolphin/api/http.rb
CHANGED
@@ -1,67 +1,70 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
require 'json'
|
3
|
-
require 'net/http'
|
4
|
-
require 'uri'
|
5
|
-
|
6
|
-
module Xolphin
|
7
|
-
module Api
|
8
|
-
class Http
|
9
|
-
LIVE_URL = "https://api.xolphin.com/v1/".freeze
|
10
|
-
TEST_URL = "https://test-api.xolphin.com/v1/".freeze
|
11
|
-
|
12
|
-
def initialize(username, password, options = {})
|
13
|
-
@username = username
|
14
|
-
@password = password
|
15
|
-
@test = options[:test]
|
16
|
-
end
|
17
|
-
|
18
|
-
def get(path, params = {})
|
19
|
-
uri = URI.parse(File.join(api_url, path))
|
20
|
-
uri.query = URI.encode_www_form(params) unless params.empty?
|
21
|
-
|
22
|
-
|
23
|
-
request.
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
request.
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
1
|
+
require 'cgi'
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
module Xolphin
|
7
|
+
module Api
|
8
|
+
class Http
|
9
|
+
LIVE_URL = "https://api.xolphin.com/v1/".freeze
|
10
|
+
TEST_URL = "https://test-api.xolphin.com/v1/".freeze
|
11
|
+
|
12
|
+
def initialize(username, password, options = {})
|
13
|
+
@username = username
|
14
|
+
@password = password
|
15
|
+
@test = options[:test]
|
16
|
+
end
|
17
|
+
|
18
|
+
def get(path, params = {})
|
19
|
+
uri = URI.parse(File.join(api_url, path))
|
20
|
+
uri.query = URI.encode_www_form(params) unless params.empty?
|
21
|
+
pkgver = Xolphin::Api::VERSION
|
22
|
+
|
23
|
+
request = Net::HTTP::Get.new(uri, {'User-Agent' => "xolphin-api-ruby/#{pkgver}"})
|
24
|
+
request.basic_auth(@username, @password)
|
25
|
+
|
26
|
+
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
27
|
+
http.request(request)
|
28
|
+
end
|
29
|
+
|
30
|
+
JSON.parse(response.body)
|
31
|
+
end
|
32
|
+
|
33
|
+
def post(path, params = {})
|
34
|
+
uri = URI.parse(File.join(api_url, path))
|
35
|
+
pkgver = Xolphin::Api::VERSION
|
36
|
+
|
37
|
+
request = Net::HTTP::Post.new(uri, {'User-Agent' => "xolphin-api-ruby/#{pkgver}"})
|
38
|
+
request.basic_auth(@username, @password)
|
39
|
+
request.set_form_data(params)
|
40
|
+
|
41
|
+
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
42
|
+
http.request(request)
|
43
|
+
end
|
44
|
+
|
45
|
+
JSON.parse(response.body)
|
46
|
+
end
|
47
|
+
|
48
|
+
def download(path, params = {})
|
49
|
+
uri = URI.parse(File.join(api_url, path))
|
50
|
+
uri.query = URI.encode_www_form(params) unless params.empty?
|
51
|
+
pkgver = Xolphin::Api::VERSION
|
52
|
+
|
53
|
+
request = Net::HTTP::Get.new(uri, {'User-Agent' => "xolphin-api-ruby/#{pkgver}"})
|
54
|
+
request.basic_auth(@username, @password)
|
55
|
+
|
56
|
+
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
57
|
+
http.request(request)
|
58
|
+
end
|
59
|
+
|
60
|
+
response.body
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def api_url
|
66
|
+
@test ? TEST_URL : LIVE_URL
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module Xolphin
|
2
|
-
module Api
|
3
|
-
module ProductType
|
4
|
-
SINGLE = "SINGLE"
|
5
|
-
MULTI = "MULTI"
|
6
|
-
WILDCARD = "WILDCARD"
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module Xolphin
|
2
|
+
module Api
|
3
|
+
module ProductType
|
4
|
+
SINGLE = "SINGLE"
|
5
|
+
MULTI = "MULTI"
|
6
|
+
WILDCARD = "WILDCARD"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -1,43 +1,43 @@
|
|
1
|
-
module Xolphin
|
2
|
-
module Api
|
3
|
-
module Responses
|
4
|
-
class Base
|
5
|
-
def initialize(data)
|
6
|
-
@data = data
|
7
|
-
end
|
8
|
-
|
9
|
-
def error?
|
10
|
-
errors || message
|
11
|
-
end
|
12
|
-
|
13
|
-
def errors
|
14
|
-
@data["errors"]
|
15
|
-
end
|
16
|
-
|
17
|
-
def message
|
18
|
-
@data["message"]
|
19
|
-
end
|
20
|
-
|
21
|
-
def page
|
22
|
-
@data["page"]
|
23
|
-
end
|
24
|
-
|
25
|
-
def pages
|
26
|
-
@data["pages"]
|
27
|
-
end
|
28
|
-
|
29
|
-
def limit
|
30
|
-
@data["limit"]
|
31
|
-
end
|
32
|
-
|
33
|
-
def total
|
34
|
-
@data["total"]
|
35
|
-
end
|
36
|
-
|
37
|
-
def _embedded
|
38
|
-
@data["_embedded"]
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
1
|
+
module Xolphin
|
2
|
+
module Api
|
3
|
+
module Responses
|
4
|
+
class Base
|
5
|
+
def initialize(data)
|
6
|
+
@data = data
|
7
|
+
end
|
8
|
+
|
9
|
+
def error?
|
10
|
+
errors || message
|
11
|
+
end
|
12
|
+
|
13
|
+
def errors
|
14
|
+
@data["errors"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def message
|
18
|
+
@data["message"]
|
19
|
+
end
|
20
|
+
|
21
|
+
def page
|
22
|
+
@data["page"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def pages
|
26
|
+
@data["pages"]
|
27
|
+
end
|
28
|
+
|
29
|
+
def limit
|
30
|
+
@data["limit"]
|
31
|
+
end
|
32
|
+
|
33
|
+
def total
|
34
|
+
@data["total"]
|
35
|
+
end
|
36
|
+
|
37
|
+
def _embedded
|
38
|
+
@data["_embedded"]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,53 +1,53 @@
|
|
1
|
-
require 'time'
|
2
|
-
|
3
|
-
module Xolphin
|
4
|
-
module Api
|
5
|
-
module Responses
|
6
|
-
class Certificate < Base
|
7
|
-
def initialize(data)
|
8
|
-
super(data)
|
9
|
-
end
|
10
|
-
|
11
|
-
def id
|
12
|
-
@data["id"]
|
13
|
-
end
|
14
|
-
|
15
|
-
def domain_name
|
16
|
-
@data["domainName"]
|
17
|
-
end
|
18
|
-
|
19
|
-
def subject_alternative_names
|
20
|
-
@data["subjectAlternativeNames"]
|
21
|
-
end
|
22
|
-
|
23
|
-
def date_issued
|
24
|
-
Time.parse(@data["dateIssued"])
|
25
|
-
end
|
26
|
-
|
27
|
-
def date_expired
|
28
|
-
Time.parse(@data["dateExpired"])
|
29
|
-
end
|
30
|
-
|
31
|
-
def company
|
32
|
-
@data["company"]
|
33
|
-
end
|
34
|
-
|
35
|
-
def customer_id
|
36
|
-
@data["customerId"]
|
37
|
-
end
|
38
|
-
|
39
|
-
def expired?
|
40
|
-
date_expired <= Time.now
|
41
|
-
end
|
42
|
-
|
43
|
-
def product
|
44
|
-
@product ||= begin
|
45
|
-
if _embedded && _embedded["product"]
|
46
|
-
Product.new(_embedded["product"])
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module Xolphin
|
4
|
+
module Api
|
5
|
+
module Responses
|
6
|
+
class Certificate < Base
|
7
|
+
def initialize(data)
|
8
|
+
super(data)
|
9
|
+
end
|
10
|
+
|
11
|
+
def id
|
12
|
+
@data["id"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def domain_name
|
16
|
+
@data["domainName"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def subject_alternative_names
|
20
|
+
@data["subjectAlternativeNames"]
|
21
|
+
end
|
22
|
+
|
23
|
+
def date_issued
|
24
|
+
Time.parse(@data["dateIssued"])
|
25
|
+
end
|
26
|
+
|
27
|
+
def date_expired
|
28
|
+
Time.parse(@data["dateExpired"])
|
29
|
+
end
|
30
|
+
|
31
|
+
def company
|
32
|
+
@data["company"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def customer_id
|
36
|
+
@data["customerId"]
|
37
|
+
end
|
38
|
+
|
39
|
+
def expired?
|
40
|
+
date_expired <= Time.now
|
41
|
+
end
|
42
|
+
|
43
|
+
def product
|
44
|
+
@product ||= begin
|
45
|
+
if _embedded && _embedded["product"]
|
46
|
+
Product.new(_embedded["product"])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
module Xolphin
|
2
|
-
module Api
|
3
|
-
module Responses
|
4
|
-
class Certificates < Base
|
5
|
-
def initialize(data)
|
6
|
-
super(data)
|
7
|
-
end
|
8
|
-
|
9
|
-
def certificates
|
10
|
-
@certificates ||= begin
|
11
|
-
certificates = []
|
12
|
-
|
13
|
-
if _embedded && _embedded["certificates"]
|
14
|
-
_embedded["certificates"].each do |certificate|
|
15
|
-
certificates << Certificate.new(certificate)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
certificates
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
1
|
+
module Xolphin
|
2
|
+
module Api
|
3
|
+
module Responses
|
4
|
+
class Certificates < Base
|
5
|
+
def initialize(data)
|
6
|
+
super(data)
|
7
|
+
end
|
8
|
+
|
9
|
+
def certificates
|
10
|
+
@certificates ||= begin
|
11
|
+
certificates = []
|
12
|
+
|
13
|
+
if _embedded && _embedded["certificates"]
|
14
|
+
_embedded["certificates"].each do |certificate|
|
15
|
+
certificates << Certificate.new(certificate)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
certificates
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,43 +1,43 @@
|
|
1
|
-
module Xolphin
|
2
|
-
module Api
|
3
|
-
module Responses
|
4
|
-
class CsrData < Base
|
5
|
-
def initialize(data)
|
6
|
-
super(data)
|
7
|
-
end
|
8
|
-
|
9
|
-
def type
|
10
|
-
@data["type"]
|
11
|
-
end
|
12
|
-
|
13
|
-
def size
|
14
|
-
@data["size"]
|
15
|
-
end
|
16
|
-
|
17
|
-
def company
|
18
|
-
@data["company"]
|
19
|
-
end
|
20
|
-
|
21
|
-
def cn
|
22
|
-
@data["cn"]
|
23
|
-
end
|
24
|
-
|
25
|
-
def state
|
26
|
-
@data["state"]
|
27
|
-
end
|
28
|
-
|
29
|
-
def city
|
30
|
-
@data["city"]
|
31
|
-
end
|
32
|
-
|
33
|
-
def country
|
34
|
-
@data["country"]
|
35
|
-
end
|
36
|
-
|
37
|
-
def alt_names
|
38
|
-
@data["altNames"]
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
1
|
+
module Xolphin
|
2
|
+
module Api
|
3
|
+
module Responses
|
4
|
+
class CsrData < Base
|
5
|
+
def initialize(data)
|
6
|
+
super(data)
|
7
|
+
end
|
8
|
+
|
9
|
+
def type
|
10
|
+
@data["type"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def size
|
14
|
+
@data["size"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def company
|
18
|
+
@data["company"]
|
19
|
+
end
|
20
|
+
|
21
|
+
def cn
|
22
|
+
@data["cn"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def state
|
26
|
+
@data["state"]
|
27
|
+
end
|
28
|
+
|
29
|
+
def city
|
30
|
+
@data["city"]
|
31
|
+
end
|
32
|
+
|
33
|
+
def country
|
34
|
+
@data["country"]
|
35
|
+
end
|
36
|
+
|
37
|
+
def alt_names
|
38
|
+
@data["altNames"]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module Xolphin
|
4
|
+
module Api
|
5
|
+
module Responses
|
6
|
+
class Invoice < Base
|
7
|
+
def initialize(data)
|
8
|
+
super(data)
|
9
|
+
end
|
10
|
+
|
11
|
+
def id
|
12
|
+
@data['id']
|
13
|
+
end
|
14
|
+
|
15
|
+
def currency
|
16
|
+
@data['currency']
|
17
|
+
end
|
18
|
+
|
19
|
+
def amount
|
20
|
+
@data['amount']
|
21
|
+
end
|
22
|
+
|
23
|
+
def tax
|
24
|
+
@data['tax']
|
25
|
+
end
|
26
|
+
|
27
|
+
def invoice_number
|
28
|
+
@data['invoiceNr']
|
29
|
+
end
|
30
|
+
|
31
|
+
def amount_paid
|
32
|
+
@data['amountPaid']
|
33
|
+
end
|
34
|
+
|
35
|
+
def status
|
36
|
+
@data['status']
|
37
|
+
end
|
38
|
+
|
39
|
+
def total
|
40
|
+
@data['total']
|
41
|
+
end
|
42
|
+
|
43
|
+
def date_created
|
44
|
+
Time.parse(@data['date_created'])
|
45
|
+
end
|
46
|
+
|
47
|
+
def date_reminder
|
48
|
+
Time.parse(@data['date_reminder'])
|
49
|
+
end
|
50
|
+
|
51
|
+
def date_payed
|
52
|
+
Time.parse(@data['date_payed'])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Xolphin
|
2
|
+
module Api
|
3
|
+
module Responses
|
4
|
+
class Invoices < Base
|
5
|
+
def initialize(data)
|
6
|
+
super(data)
|
7
|
+
end
|
8
|
+
|
9
|
+
def invoices
|
10
|
+
@invoices ||= begin
|
11
|
+
invoices = []
|
12
|
+
|
13
|
+
if _embedded && _embedded["invoices"]
|
14
|
+
_embedded["invoices"].each do |invoice|
|
15
|
+
invoices << Invoice.new(invoice)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
invoices
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,37 +1,45 @@
|
|
1
|
-
require 'time'
|
2
|
-
|
3
|
-
module Xolphin
|
4
|
-
module Api
|
5
|
-
module Responses
|
6
|
-
class Note < Base
|
7
|
-
def initialize(data)
|
8
|
-
super(data)
|
9
|
-
end
|
10
|
-
|
11
|
-
def
|
12
|
-
@data["
|
13
|
-
end
|
14
|
-
|
15
|
-
def
|
16
|
-
@data["
|
17
|
-
end
|
18
|
-
|
19
|
-
def
|
20
|
-
@data["
|
21
|
-
end
|
22
|
-
|
23
|
-
def
|
24
|
-
@data["
|
25
|
-
end
|
26
|
-
|
27
|
-
def
|
28
|
-
@data["
|
29
|
-
end
|
30
|
-
|
31
|
-
def
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module Xolphin
|
4
|
+
module Api
|
5
|
+
module Responses
|
6
|
+
class Note < Base
|
7
|
+
def initialize(data)
|
8
|
+
super(data)
|
9
|
+
end
|
10
|
+
|
11
|
+
def id
|
12
|
+
@data["id"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def contact
|
16
|
+
@data["contact"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def staff
|
20
|
+
@data["staff"]
|
21
|
+
end
|
22
|
+
|
23
|
+
def date
|
24
|
+
@data["date"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def time
|
28
|
+
@data["time"]
|
29
|
+
end
|
30
|
+
|
31
|
+
def message_body
|
32
|
+
@data["message"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def created_at
|
36
|
+
Time.parse(@data["createdAt"])
|
37
|
+
end
|
38
|
+
|
39
|
+
def end_customer
|
40
|
+
@data['endCustomer']
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|