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.
Files changed (62) 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.rb +40 -0
  20. data/examples/request_create_ee.rb +29 -29
  21. data/examples/request_get_id.rb +6 -0
  22. data/examples/request_validation_call.rb +6 -5
  23. data/examples/requests_get.rb +8 -7
  24. data/examples/send_csa_email.rb +5 -5
  25. data/examples/send_note.rb +6 -6
  26. data/lib/xolphin/api/certificate_requests/certificate_reissue.rb +54 -47
  27. data/lib/xolphin/api/certificate_requests/certificate_renew.rb +58 -51
  28. data/lib/xolphin/api/certificate_requests/create_certificate_request.rb +59 -52
  29. data/lib/xolphin/api/certificate_requests/create_ee_request.rb +28 -33
  30. data/lib/xolphin/api/client.rb +25 -21
  31. data/lib/xolphin/api/dcv_type.rb +9 -9
  32. data/lib/xolphin/api/endpoint/certificate.rb +59 -59
  33. data/lib/xolphin/api/endpoint/invoice.rb +40 -0
  34. data/lib/xolphin/api/endpoint/request.rb +116 -86
  35. data/lib/xolphin/api/endpoint/support.rb +47 -47
  36. data/lib/xolphin/api/format_type.rb +12 -12
  37. data/lib/xolphin/api/http.rb +70 -67
  38. data/lib/xolphin/api/invoice_format_type.rb +8 -0
  39. data/lib/xolphin/api/product_type.rb +9 -9
  40. data/lib/xolphin/api/responses/base.rb +43 -43
  41. data/lib/xolphin/api/responses/certificate.rb +53 -53
  42. data/lib/xolphin/api/responses/certificates.rb +25 -25
  43. data/lib/xolphin/api/responses/csr_data.rb +43 -43
  44. data/lib/xolphin/api/responses/invoice.rb +57 -0
  45. data/lib/xolphin/api/responses/invoices.rb +25 -0
  46. data/lib/xolphin/api/responses/note.rb +45 -37
  47. data/lib/xolphin/api/responses/notes.rb +23 -24
  48. data/lib/xolphin/api/responses/product.rb +53 -53
  49. data/lib/xolphin/api/responses/product_price.rb +27 -27
  50. data/lib/xolphin/api/responses/products.rb +25 -25
  51. data/lib/xolphin/api/responses/request.rb +142 -119
  52. data/lib/xolphin/api/responses/request_ee.rb +29 -29
  53. data/lib/xolphin/api/responses/request_validation.rb +37 -37
  54. data/lib/xolphin/api/responses/request_validation_domain.rb +51 -35
  55. data/lib/xolphin/api/responses/requests.rb +25 -25
  56. data/lib/xolphin/api/responses/validation_call.rb +23 -0
  57. data/lib/xolphin/api/responses/validation_calls.rb +25 -0
  58. data/lib/xolphin/api/version.rb +5 -5
  59. data/lib/xolphin/api.rb +38 -32
  60. data/xolphin-api.gemspec +25 -26
  61. metadata +19 -9
  62. data/xolphin-api-0.1.0.gem +0 -0
@@ -1,33 +1,28 @@
1
- require 'json'
2
-
3
- module Xolphin
4
- module Api
5
- module CertificateRequests
6
- class CreateEERequest
7
- attr_accessor :csr, :dcv_type, :subject_alternative_names, :validate
8
- attr_accessor :approver_first_name, :approver_last_name, :approver_email, :approver_phone
9
-
10
- def to_param
11
- result = {
12
- "csr" => @csr,
13
- "dcvType" => @dcv_type,
14
- "approverFirstName" => @approver_first_name,
15
- "approverLastName" => @approver_last_name,
16
- "approverEmail" => @approver_email,
17
- "approverPhone" => @approver_phone,
18
- }
19
-
20
- if @validate
21
- result['validate'] = true;
22
- end
23
-
24
- if @subject_alternative_names
25
- result["subjectAlternativeNames"] = @subject_alternative_names.join(",")
26
- end
27
-
28
- result
29
- end
30
- end
31
- end
32
- end
33
- end
1
+ require 'json'
2
+
3
+ module Xolphin
4
+ module Api
5
+ module CertificateRequests
6
+ class CreateEERequest
7
+ attr_accessor :csr, :dcv_type, :subject_alternative_names, :validate
8
+ attr_accessor :approver_first_name, :approver_last_name, :approver_email, :approver_phone
9
+
10
+ def to_param
11
+ result = {
12
+ "csr" => @csr,
13
+ "dcvType" => @dcv_type,
14
+ "approverFirstName" => @approver_first_name,
15
+ "approverLastName" => @approver_last_name,
16
+ "approverEmail" => @approver_email,
17
+ "approverPhone" => @approver_phone
18
+ }
19
+
20
+ result['validate'] = true if @validate
21
+ result["subjectAlternativeNames"] = @subject_alternative_names.join(",") if @subject_alternative_names
22
+
23
+ result
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -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,116 @@
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 RequestDeprecate
7
+ extend Gem::Deprecate
8
+
9
+ def initialize(http)
10
+ @http = http
11
+ end
12
+
13
+ def _send()
14
+ end
15
+
16
+ deprecate :_send, 'The [approverFirstName, approverLastName, approverPhone] fields are deprecated please use [approverRepresentativeFirstName, approverRepresentativeLastName, approverRepresentativePhone].', 2023, 11
17
+ end
18
+
19
+ class Request
20
+
21
+ def initialize(http)
22
+ @http = http
23
+ @deprecated = RequestDeprecate.new(@http)
24
+ end
25
+
26
+ def all
27
+ requests = []
28
+
29
+ result = @http.get("/requests", page: 1)
30
+ response = Xolphin::Api::Responses::Requests.new(result)
31
+
32
+ unless response.error?
33
+ requests = response.requests
34
+ while response.page < response.pages
35
+ result = @http.get("/requests", page: response.page + 1)
36
+ response = Xolphin::Api::Responses::Requests.new(result)
37
+ break if response.error?
38
+
39
+ requests += response.requests
40
+ end
41
+ end
42
+
43
+ requests
44
+ end
45
+
46
+ def get(id)
47
+ result = @http.get("/requests/#{id}")
48
+
49
+ Xolphin::Api::Responses::Request.new(result)
50
+ end
51
+
52
+ def create(product, years, csr, dcv_type)
53
+ Xolphin::Api::CertificateRequests::CreateCertificateRequest.new(product, years, csr, dcv_type)
54
+ end
55
+
56
+ def send(request)
57
+ requestParams = request.to_param
58
+ deprecatedFields = ["approverFirstName", "approverLastName", "approverPhone"]
59
+
60
+ if deprecatedFields.any? { |element| requestParams.include?(element) }
61
+ @deprecated._send()
62
+ end
63
+
64
+ result = @http.post("/requests", requestParams)
65
+
66
+ Xolphin::Api::Responses::Request.new(result)
67
+ end
68
+
69
+ def createEE
70
+ Xolphin::Api::CertificateRequests::CreateEERequest.new
71
+ end
72
+
73
+ def sendEE(request)
74
+ result = @http.post("/requests/ee", request.to_param)
75
+
76
+ Xolphin::Api::Responses::RequestEE.new(result)
77
+ end
78
+
79
+ def sendNote(id, note)
80
+ @http.post("/requests/#{id}/notes", 'message' => note)
81
+ end
82
+
83
+ def getNotes(id)
84
+ result = @http.get("/requests/#{id}/notes")
85
+
86
+ Xolphin::Api::Responses::Notes.new(result)
87
+ end
88
+
89
+ def scheduleValidationCall(id, date_time, extra = nil)
90
+ t = Time.parse(date_time)
91
+ params = { 'date' => t.strftime("%Y-%m-%d"), 'time' => t.strftime("%H:%M") }
92
+
93
+ params.merge!(extra) if extra.is_a?(Hash)
94
+
95
+ @http.post("requests/#{id}/schedule-validation-call", params)
96
+ end
97
+
98
+ def sendComodoSAEmail(id, to, language = nil)
99
+ @http.post("requests/#{id}/sa", 'sa_email' => to, 'language' => language)
100
+ end
101
+
102
+ def upload(id, document, description = nil)
103
+ @http.post("requests/#{id}/upload-document", 'document' => document, 'description' => description)
104
+ end
105
+
106
+ def retryDCV(id, domain, dcv_type, email = nil)
107
+ @http.post("requests/#{id}/retry-dcv", "domain" => domain, "dcvType" => dcv_type, "email" => email)
108
+ end
109
+
110
+ def cancel(id, reason = "")
111
+ @http.post("requests/#{id}/cancel", "reason" => reason)
112
+ end
113
+ end
114
+ end
115
+ end
116
+ 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