point 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/point.rb +2 -4
- data/lib/point/errors.rb +5 -6
- data/lib/point/request.rb +13 -10
- metadata +13 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 42f7120c69d882c7f68cd1bc646167776ef34d56
|
4
|
+
data.tar.gz: f4a49f47ad1af09a67800d84e95eb1a159d7f368
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c0e48a841a51d3d564952f5f813429acf830a9395086a1f77fbd7a72af06516f90d405cec3e43b57e41d95820b99e1d5413a08cb2de0e355585d4c53a524064
|
7
|
+
data.tar.gz: 0b4609d5d13611f2471dc19035149a52eb252b0b204d34a1c9d79c7e8912c52aef17b0eee86f561a1cf6b2999d0d72ae82cd784837a35dd19df4da6df3b206f4
|
data/lib/point.rb
CHANGED
@@ -15,14 +15,12 @@ require 'point/zone'
|
|
15
15
|
require 'point/zone_record'
|
16
16
|
|
17
17
|
module Point
|
18
|
-
VERSION = '1.0
|
19
|
-
|
18
|
+
VERSION = '1.1.0'
|
20
19
|
class << self
|
21
20
|
attr_accessor :username
|
22
21
|
attr_accessor :apitoken
|
23
22
|
attr_accessor :site
|
24
23
|
end
|
25
|
-
|
26
24
|
end
|
27
25
|
|
28
|
-
Point.site =
|
26
|
+
Point.site = 'https://api.pointhq.com'
|
data/lib/point/errors.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
module Point
|
2
|
-
|
2
|
+
|
3
3
|
## Base level error which all other point errors will inherit from. It may also be
|
4
4
|
## invoked for errors which don't directly relate to other errors below.
|
5
5
|
class Error < StandardError; end
|
6
|
-
|
6
|
+
|
7
7
|
module Errors
|
8
|
-
|
8
|
+
|
9
9
|
## The service is currently unavailable. This may be caused by rate limiting or the API
|
10
10
|
## or the service has been disabled by the system
|
11
11
|
class ServiceUnavailable < Error; end
|
12
|
-
|
12
|
+
|
13
13
|
## Access was denied to the remote service
|
14
14
|
class AccessDenied < Error; end
|
15
|
-
|
15
|
+
|
16
16
|
## A communication error occured while talking to the Point API
|
17
17
|
class CommunicationError < Error; end
|
18
|
-
|
19
18
|
end
|
20
19
|
end
|
data/lib/point/request.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
module Point
|
2
2
|
class Request
|
3
|
-
|
3
|
+
|
4
4
|
attr_reader :path, :method
|
5
5
|
attr_accessor :data
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(path, method = :get)
|
8
8
|
@path = path
|
9
9
|
@method = method
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def success?
|
13
13
|
@success || false
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def output
|
17
17
|
@output || nil
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
## Make a request to the Point API using net/http. Data passed can be a hash or a string
|
21
21
|
## Hashes will be converted to JSON before being sent to the remote service.
|
22
22
|
def make
|
@@ -25,8 +25,9 @@ module Point
|
|
25
25
|
http_request.basic_auth(Point.username, Point.apitoken)
|
26
26
|
http_request.add_field("Accept", "application/json")
|
27
27
|
http_request.add_field("Content-type", "application/json")
|
28
|
-
|
28
|
+
|
29
29
|
http = Net::HTTP.new(uri.host, uri.port)
|
30
|
+
http.use_ssl = true
|
30
31
|
data = self.data.to_json if self.data.is_a?(Hash) && self.data.respond_to?(:to_json)
|
31
32
|
http_result = http.request(http_request, data)
|
32
33
|
@output = http_result.body
|
@@ -39,6 +40,8 @@ module Point
|
|
39
40
|
raise Point::Errors::AccessDenied, "Access Denied for '#{Point.username}'"
|
40
41
|
when Net::HTTPNotFound
|
41
42
|
raise Point::Errors::CommunicationError, "Not Found at #{uri.to_s}"
|
43
|
+
when Net::HTTPPaymentRequired
|
44
|
+
raise Point::Errors::AccessDenied, JSON.parse(output)['message']
|
42
45
|
when Net::HTTPClientError
|
43
46
|
false
|
44
47
|
else
|
@@ -46,10 +49,10 @@ module Point
|
|
46
49
|
end
|
47
50
|
self
|
48
51
|
end
|
49
|
-
|
52
|
+
|
50
53
|
private
|
51
|
-
|
52
|
-
def http_class
|
54
|
+
|
55
|
+
def http_class
|
53
56
|
case @method
|
54
57
|
when :post then Net::HTTP::Post
|
55
58
|
when :put then Net::HTTP::Put
|
@@ -58,6 +61,6 @@ module Point
|
|
58
61
|
Net::HTTP::Get
|
59
62
|
end
|
60
63
|
end
|
61
|
-
|
64
|
+
|
62
65
|
end
|
63
66
|
end
|
metadata
CHANGED
@@ -1,66 +1,62 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: point
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
|
-
-
|
7
|
+
- Cogneto.io
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-11-04 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: json
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 1.1.5
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 1.1.5
|
30
27
|
description:
|
31
|
-
email:
|
28
|
+
email: hello@cogneto.io
|
32
29
|
executables: []
|
33
30
|
extensions: []
|
34
31
|
extra_rdoc_files: []
|
35
32
|
files:
|
33
|
+
- lib/point.rb
|
36
34
|
- lib/point/base.rb
|
37
35
|
- lib/point/errors.rb
|
38
36
|
- lib/point/request.rb
|
39
37
|
- lib/point/zone.rb
|
40
38
|
- lib/point/zone_record.rb
|
41
|
-
|
42
|
-
homepage: http://www.pointhq.com
|
39
|
+
homepage: https://www.pointhq.com
|
43
40
|
licenses: []
|
41
|
+
metadata: {}
|
44
42
|
post_install_message:
|
45
43
|
rdoc_options: []
|
46
44
|
require_paths:
|
47
45
|
- lib
|
48
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
47
|
requirements:
|
51
|
-
- -
|
48
|
+
- - ">="
|
52
49
|
- !ruby/object:Gem::Version
|
53
50
|
version: '0'
|
54
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
52
|
requirements:
|
57
|
-
- -
|
53
|
+
- - ">="
|
58
54
|
- !ruby/object:Gem::Version
|
59
55
|
version: '0'
|
60
56
|
requirements: []
|
61
57
|
rubyforge_project:
|
62
|
-
rubygems_version:
|
58
|
+
rubygems_version: 2.5.1
|
63
59
|
signing_key:
|
64
|
-
specification_version:
|
60
|
+
specification_version: 4
|
65
61
|
summary: API client for the PointHQ DNS Hosting System
|
66
62
|
test_files: []
|