xolphin-api 1.5.0 → 1.8.0

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.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +13 -12
  3. data/.rspec +2 -2
  4. data/.rubocop.yml +28 -28
  5. data/.travis.yml +5 -5
  6. data/CHANGELOG.md +19 -0
  7. data/Gemfile +6 -6
  8. data/LICENSE.txt +21 -21
  9. data/README.md +169 -169
  10. data/Rakefile +12 -12
  11. data/bin/console +14 -14
  12. data/bin/setup +8 -8
  13. data/examples/_credentials.rb +9 -8
  14. data/examples/certificate_cancel.rb +6 -6
  15. data/examples/certificate_reissue.rb +23 -25
  16. data/examples/certificate_renew.rb +22 -22
  17. data/examples/get_notes.rb +9 -9
  18. data/examples/invoices_get.rb +7 -0
  19. data/examples/request_create_ee.rb +29 -29
  20. data/examples/request_validation_call.rb +5 -5
  21. data/examples/requests_get.rb +7 -7
  22. data/examples/send_csa_email.rb +5 -5
  23. data/examples/send_note.rb +6 -6
  24. data/lib/xolphin/api/certificate_requests/certificate_reissue.rb +47 -47
  25. data/lib/xolphin/api/certificate_requests/certificate_renew.rb +51 -51
  26. data/lib/xolphin/api/certificate_requests/create_certificate_request.rb +53 -52
  27. data/lib/xolphin/api/certificate_requests/create_ee_request.rb +28 -33
  28. data/lib/xolphin/api/client.rb +25 -21
  29. data/lib/xolphin/api/dcv_type.rb +9 -9
  30. data/lib/xolphin/api/endpoint/certificate.rb +59 -59
  31. data/lib/xolphin/api/endpoint/invoice.rb +40 -0
  32. data/lib/xolphin/api/endpoint/request.rb +90 -86
  33. data/lib/xolphin/api/endpoint/support.rb +47 -47
  34. data/lib/xolphin/api/format_type.rb +12 -12
  35. data/lib/xolphin/api/http.rb +67 -67
  36. data/lib/xolphin/api/invoice_format_type.rb +8 -0
  37. data/lib/xolphin/api/product_type.rb +9 -9
  38. data/lib/xolphin/api/responses/base.rb +43 -43
  39. data/lib/xolphin/api/responses/certificate.rb +53 -53
  40. data/lib/xolphin/api/responses/certificates.rb +25 -25
  41. data/lib/xolphin/api/responses/csr_data.rb +43 -43
  42. data/lib/xolphin/api/responses/invoice.rb +57 -0
  43. data/lib/xolphin/api/responses/invoices.rb +25 -0
  44. data/lib/xolphin/api/responses/note.rb +45 -37
  45. data/lib/xolphin/api/responses/notes.rb +23 -24
  46. data/lib/xolphin/api/responses/product.rb +53 -53
  47. data/lib/xolphin/api/responses/product_price.rb +27 -27
  48. data/lib/xolphin/api/responses/products.rb +25 -25
  49. data/lib/xolphin/api/responses/request.rb +119 -119
  50. data/lib/xolphin/api/responses/request_ee.rb +29 -29
  51. data/lib/xolphin/api/responses/request_validation.rb +37 -37
  52. data/lib/xolphin/api/responses/request_validation_domain.rb +51 -35
  53. data/lib/xolphin/api/responses/requests.rb +25 -25
  54. data/lib/xolphin/api/responses/validation_call.rb +23 -0
  55. data/lib/xolphin/api/responses/validation_calls.rb +25 -0
  56. data/lib/xolphin/api/version.rb +5 -5
  57. data/lib/xolphin/api.rb +38 -32
  58. data/xolphin-api.gemspec +25 -26
  59. metadata +17 -9
  60. data/xolphin-api-0.1.0.gem +0 -0
@@ -1,21 +1,25 @@
1
- module Xolphin
2
- module Api
3
- class Client
4
- def initialize(username, password, test = false)
5
- @http = Xolphin::Api::Http.new(username, password, test: test)
6
- end
7
-
8
- def request
9
- Xolphin::Api::Endpoint::Request.new(@http)
10
- end
11
-
12
- def certificate
13
- Xolphin::Api::Endpoint::Certificate.new(@http)
14
- end
15
-
16
- def support
17
- Xolphin::Api::Endpoint::Support.new(@http)
18
- end
19
- end
20
- end
21
- end
1
+ module Xolphin
2
+ module Api
3
+ class Client
4
+ def initialize(username, password, test = false)
5
+ @http = Xolphin::Api::Http.new(username, password, test: test)
6
+ end
7
+
8
+ def request
9
+ Xolphin::Api::Endpoint::Request.new(@http)
10
+ end
11
+
12
+ def certificate
13
+ Xolphin::Api::Endpoint::Certificate.new(@http)
14
+ end
15
+
16
+ def support
17
+ Xolphin::Api::Endpoint::Support.new(@http)
18
+ end
19
+
20
+ def invoice
21
+ Xolphin::Api::Endpoint::Invoice.new(@http)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,9 +1,9 @@
1
- module Xolphin
2
- module Api
3
- module DcvType
4
- EMAIL = "EMAIL"
5
- FILE = "FILE"
6
- DNS = "DNS"
7
- end
8
- end
9
- end
1
+ module Xolphin
2
+ module Api
3
+ module DcvType
4
+ EMAIL = "EMAIL"
5
+ FILE = "FILE"
6
+ DNS = "DNS"
7
+ end
8
+ end
9
+ end
@@ -1,59 +1,59 @@
1
- module Xolphin
2
- module Api
3
- module Endpoint
4
- class Certificate
5
- def initialize(http)
6
- @http = http
7
- end
8
-
9
- def all
10
- certificates = []
11
-
12
- result = @http.get("/certificates", page: 1)
13
- response = Xolphin::Api::Responses::Certificates.new(result)
14
-
15
- unless response.error?
16
- certificates = response.certificates
17
- while response.page < response.pages
18
- result = @http.get("/certificates", page: response.page + 1)
19
- response = Xolphin::Api::Responses::Certificates.new(result)
20
- break if response.error?
21
-
22
- certificates += response.certificates
23
- end
24
- end
25
-
26
- certificates
27
- end
28
-
29
- def get(id)
30
- result = @http.get("/certificates/#{id}")
31
-
32
- Xolphin::Api::Responses::Certificate.new(result)
33
- end
34
-
35
- def download(id, format = Xolphin::Api::FormatType::CRT)
36
- @http.download("/certificates/#{id}/download", format: format)
37
- end
38
-
39
- def reissue(id, request)
40
- result = @http.post("/certificates/#{id}/reissue", request.to_param)
41
- response = Xolphin::Api::Responses::Requests.new(result)
42
- end
43
-
44
- def renew(id, request)
45
- result = @http.post("/certificates/#{id}/renew", request.to_param)
46
- response = Xolphin::Api::Responses::Requests.new(result)
47
- end
48
-
49
- def cancel(id, reason, revoke = nil)
50
- revoke ||= false
51
- @http.post("/certificates/#{id}/cancel", [
52
- 'reason' => reason,
53
- 'revoke' => revoke
54
- ])
55
- end
56
- end
57
- end
58
- end
59
- end
1
+ module Xolphin
2
+ module Api
3
+ module Endpoint
4
+ class Certificate
5
+ def initialize(http)
6
+ @http = http
7
+ end
8
+
9
+ def all
10
+ certificates = []
11
+
12
+ result = @http.get("/certificates", page: 1)
13
+ response = Xolphin::Api::Responses::Certificates.new(result)
14
+
15
+ unless response.error?
16
+ certificates = response.certificates
17
+ while response.page < response.pages
18
+ result = @http.get("/certificates", page: response.page + 1)
19
+ response = Xolphin::Api::Responses::Certificates.new(result)
20
+ break if response.error?
21
+
22
+ certificates += response.certificates
23
+ end
24
+ end
25
+
26
+ certificates
27
+ end
28
+
29
+ def get(id)
30
+ result = @http.get("/certificates/#{id}")
31
+
32
+ Xolphin::Api::Responses::Certificate.new(result)
33
+ end
34
+
35
+ def download(id, format = Xolphin::Api::FormatType::CRT)
36
+ @http.download("/certificates/#{id}/download", format: format)
37
+ end
38
+
39
+ def reissue(id, request)
40
+ result = @http.post("/certificates/#{id}/reissue", request.to_param)
41
+ Xolphin::Api::Responses::Requests.new(result)
42
+ end
43
+
44
+ def renew(id, request)
45
+ result = @http.post("/certificates/#{id}/renew", request.to_param)
46
+ Xolphin::Api::Responses::Requests.new(result)
47
+ end
48
+
49
+ def cancel(id, reason, revoke = nil)
50
+ revoke ||= false
51
+ @http.post("/certificates/#{id}/cancel", [
52
+ 'reason' => reason,
53
+ 'revoke' => revoke
54
+ ])
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,40 @@
1
+ module Xolphin
2
+ module Api
3
+ module Endpoint
4
+ class Invoice
5
+ def initialize(http)
6
+ @http = http
7
+ end
8
+
9
+ def all
10
+ invoices = []
11
+
12
+ result = @http.get("/invoices", page: 1)
13
+ response = Xolphin::Api::Responses::Invoices.new(result)
14
+
15
+ unless response.error?
16
+ invoices = response.invoices
17
+ while response.page < response.pages
18
+ result = @http.get("/invoices", page: response.page + 1)
19
+ response = Xolphin::Api::Responses::Invoices.new(result)
20
+ break if response.error?
21
+
22
+ invoices += response.invoices
23
+ end
24
+ end
25
+
26
+ invoices
27
+ end
28
+
29
+ def get(id)
30
+ result = @http.get("/invoices/#{id}")
31
+ Xolphin::Api::Responses::Invoice.new(result)
32
+ end
33
+
34
+ def download(id, type = "PDF")
35
+ @http.download("/invoices/#{id}/download", type: type)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,86 +1,90 @@
1
- require 'time'
2
-
3
- module Xolphin
4
- module Api
5
- module Endpoint
6
- class Request
7
- def initialize(http)
8
- @http = http
9
- end
10
-
11
- def all
12
- requests = []
13
-
14
- result = @http.get("/requests", page: 1)
15
- response = Xolphin::Api::Responses::Requests.new(result)
16
-
17
- unless response.error?
18
- requests = response.requests
19
- while response.page < response.pages
20
- result = @http.get("/requests", page: response.page + 1)
21
- response = Xolphin::Api::Responses::Requests.new(result)
22
- break if response.error?
23
-
24
- requests += response.requests
25
- end
26
- end
27
-
28
- requests
29
- end
30
-
31
- def get(id)
32
- result = @http.get("/requests/#{id}")
33
-
34
- Xolphin::Api::Responses::Request.new(result)
35
- end
36
-
37
- def create(product, years, csr, dcv_type)
38
- Xolphin::Api::CertificateRequests::CreateCertificateRequest.new(product, years, csr, dcv_type)
39
- end
40
-
41
- def send(request)
42
- result = @http.post("/requests", request.to_param)
43
-
44
- Xolphin::Api::Responses::Request.new(result)
45
- end
46
-
47
- def createEE()
48
- Xolphin::Api::CertificateRequests::CreateEERequest.new()
49
- end
50
-
51
- def sendEE(request)
52
- result = @http.post("/requests/ee", request.to_param)
53
-
54
- Xolphin::Api::Responses::RequestEE.new(result)
55
- end
56
-
57
- def sendNote(id, note)
58
- @http.post("/requests/#{id}/notes",{'message' => note})
59
- end
60
-
61
- def getNotes(id)
62
- result = @http.get("/requests/#{id}/notes")
63
-
64
- Xolphin::Api::Responses::Notes.new(result)
65
- end
66
-
67
- def sendComodoSAEmail(id, to, language = nil)
68
- @http.post("requests/#{id}/sa",{'sa_email' => to, 'language' => language})
69
- end
70
-
71
- def upload(id, document, description = nil)
72
- @http.post("requests/#{id}/upload-document",{'document' => document, 'description' => description})
73
- end
74
-
75
- def scheduleValidationCall(id, date_time)
76
- t = Time.parse(date_time)
77
- @http.post("requests/#{id}/schedule-validation-call",{'date' => t.strftime("%Y-%m-%d"), 'time' => t.strftime("%H:%M")})
78
- end
79
-
80
- def retryDCV(id, domain, dcv_type, email = nil)
81
- @http.post("requests/#{id}/retry-dcv",{"domain" => domain, "dcvType" => dcv_type, "email" => email})
82
- end
83
- end
84
- end
85
- end
86
- end
1
+ require 'time'
2
+
3
+ module Xolphin
4
+ module Api
5
+ module Endpoint
6
+ class Request
7
+ def initialize(http)
8
+ @http = http
9
+ end
10
+
11
+ def all
12
+ requests = []
13
+
14
+ result = @http.get("/requests", page: 1)
15
+ response = Xolphin::Api::Responses::Requests.new(result)
16
+
17
+ unless response.error?
18
+ requests = response.requests
19
+ while response.page < response.pages
20
+ result = @http.get("/requests", page: response.page + 1)
21
+ response = Xolphin::Api::Responses::Requests.new(result)
22
+ break if response.error?
23
+
24
+ requests += response.requests
25
+ end
26
+ end
27
+
28
+ requests
29
+ end
30
+
31
+ def get(id)
32
+ result = @http.get("/requests/#{id}")
33
+
34
+ Xolphin::Api::Responses::Request.new(result)
35
+ end
36
+
37
+ def create(product, years, csr, dcv_type)
38
+ Xolphin::Api::CertificateRequests::CreateCertificateRequest.new(product, years, csr, dcv_type)
39
+ end
40
+
41
+ def send(request)
42
+ result = @http.post("/requests", request.to_param)
43
+
44
+ Xolphin::Api::Responses::Request.new(result)
45
+ end
46
+
47
+ def createEE
48
+ Xolphin::Api::CertificateRequests::CreateEERequest.new
49
+ end
50
+
51
+ def sendEE(request)
52
+ result = @http.post("/requests/ee", request.to_param)
53
+
54
+ Xolphin::Api::Responses::RequestEE.new(result)
55
+ end
56
+
57
+ def sendNote(id, note)
58
+ @http.post("/requests/#{id}/notes", 'message' => note)
59
+ end
60
+
61
+ def getNotes(id)
62
+ result = @http.get("/requests/#{id}/notes")
63
+
64
+ Xolphin::Api::Responses::Notes.new(result)
65
+ end
66
+
67
+ def sendComodoSAEmail(id, to, language = nil)
68
+ @http.post("requests/#{id}/sa", 'sa_email' => to, 'language' => language)
69
+ end
70
+
71
+ def upload(id, document, description = nil)
72
+ @http.post("requests/#{id}/upload-document", 'document' => document, 'description' => description)
73
+ end
74
+
75
+ def scheduleValidationCall(id, date_time)
76
+ t = Time.parse(date_time)
77
+ @http.post("requests/#{id}/schedule-validation-call", 'date' => t.strftime("%Y-%m-%d"), 'time' => t.strftime("%H:%M"))
78
+ end
79
+
80
+ def retryDCV(id, domain, dcv_type, email = nil)
81
+ @http.post("requests/#{id}/retry-dcv", "domain" => domain, "dcvType" => dcv_type, "email" => email)
82
+ end
83
+
84
+ def cancel(id, reason = "")
85
+ @http.post("requests/#{id}/cancel", "reason" => reason)
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -1,47 +1,47 @@
1
- module Xolphin
2
- module Api
3
- module Endpoint
4
- class Support
5
- def initialize(http)
6
- @http = http
7
- end
8
-
9
- def products
10
- products = []
11
-
12
- result = @http.get("/products", page: 1)
13
- response = Xolphin::Api::Responses::Products.new(result)
14
-
15
- unless response.error?
16
- products = response.products
17
- while response.page < response.pages
18
- result = @http.get("/products", page: response.page + 1)
19
- response = Xolphin::Api::Responses::Products.new(result)
20
- break if response.error?
21
-
22
- products += response.products
23
- end
24
- end
25
-
26
- products
27
- end
28
-
29
- def product(id)
30
- result = @http.get("/products/#{id}")
31
-
32
- Xolphin::Api::Responses::Product.new(result)
33
- end
34
-
35
- def decode_csr(csr)
36
- result = @http.post("/decode-csr", csr: csr)
37
-
38
- Xolphin::Api::Responses::CsrData.new(result)
39
- end
40
-
41
- def approver_email_addresses(domain)
42
- @http.get("/approver-email-addresses", domain: domain)
43
- end
44
- end
45
- end
46
- end
47
- end
1
+ module Xolphin
2
+ module Api
3
+ module Endpoint
4
+ class Support
5
+ def initialize(http)
6
+ @http = http
7
+ end
8
+
9
+ def products
10
+ products = []
11
+
12
+ result = @http.get("/products", page: 1)
13
+ response = Xolphin::Api::Responses::Products.new(result)
14
+
15
+ unless response.error?
16
+ products = response.products
17
+ while response.page < response.pages
18
+ result = @http.get("/products", page: response.page + 1)
19
+ response = Xolphin::Api::Responses::Products.new(result)
20
+ break if response.error?
21
+
22
+ products += response.products
23
+ end
24
+ end
25
+
26
+ products
27
+ end
28
+
29
+ def product(id)
30
+ result = @http.get("/products/#{id}")
31
+
32
+ Xolphin::Api::Responses::Product.new(result)
33
+ end
34
+
35
+ def decode_csr(csr)
36
+ result = @http.post("/decode-csr", csr: csr)
37
+
38
+ Xolphin::Api::Responses::CsrData.new(result)
39
+ end
40
+
41
+ def approver_email_addresses(domain)
42
+ @http.get("/approver-email-addresses", domain: domain)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,12 +1,12 @@
1
- module Xolphin
2
- module Api
3
- module FormatType
4
- CSR = "CSR"
5
- CRT = "CRT"
6
- ZIP = "ZIP"
7
- PKCS7 = "PKCS7"
8
- CA = "CA"
9
- CA_BUNDLE = "CA_BUNDLE"
10
- end
11
- end
12
- end
1
+ module Xolphin
2
+ module Api
3
+ module FormatType
4
+ CSR = "CSR"
5
+ CRT = "CRT"
6
+ ZIP = "ZIP"
7
+ PKCS7 = "PKCS7"
8
+ CA = "CA"
9
+ CA_BUNDLE = "CA_BUNDLE"
10
+ end
11
+ end
12
+ end
@@ -1,67 +1,67 @@
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
- request = Net::HTTP::Get.new(uri)
23
- request.basic_auth(@username, @password)
24
-
25
- response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
26
- http.request(request)
27
- end
28
-
29
- JSON.parse(response.body)
30
- end
31
-
32
- def post(path, params = {})
33
- uri = URI.parse(File.join(api_url, path))
34
-
35
- request = Net::HTTP::Post.new(uri)
36
- request.basic_auth(@username, @password)
37
- request.set_form_data(params)
38
-
39
- response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
40
- http.request(request)
41
- end
42
-
43
- JSON.parse(response.body)
44
- end
45
-
46
- def download(path, params = {})
47
- uri = URI.parse(File.join(api_url, path))
48
- uri.query = URI.encode_www_form(params) unless params.empty?
49
-
50
- request = Net::HTTP::Get.new(uri)
51
- request.basic_auth(@username, @password)
52
-
53
- response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
54
- http.request(request)
55
- end
56
-
57
- response.body
58
- end
59
-
60
- private
61
-
62
- def api_url
63
- @test ? TEST_URL : LIVE_URL
64
- end
65
- end
66
- end
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
+
22
+ request = Net::HTTP::Get.new(uri)
23
+ request.basic_auth(@username, @password)
24
+
25
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
26
+ http.request(request)
27
+ end
28
+
29
+ JSON.parse(response.body)
30
+ end
31
+
32
+ def post(path, params = {})
33
+ uri = URI.parse(File.join(api_url, path))
34
+
35
+ request = Net::HTTP::Post.new(uri)
36
+ request.basic_auth(@username, @password)
37
+ request.set_form_data(params)
38
+
39
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
40
+ http.request(request)
41
+ end
42
+
43
+ JSON.parse(response.body)
44
+ end
45
+
46
+ def download(path, params = {})
47
+ uri = URI.parse(File.join(api_url, path))
48
+ uri.query = URI.encode_www_form(params) unless params.empty?
49
+
50
+ request = Net::HTTP::Get.new(uri)
51
+ request.basic_auth(@username, @password)
52
+
53
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
54
+ http.request(request)
55
+ end
56
+
57
+ response.body
58
+ end
59
+
60
+ private
61
+
62
+ def api_url
63
+ @test ? TEST_URL : LIVE_URL
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,8 @@
1
+ module Xolphin
2
+ module Api
3
+ class InvoiceFormatType
4
+ PDF = "PDF"
5
+ UBL = "UBL"
6
+ end
7
+ end
8
+ end