rubyflare 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5c4282051f85736049fbb8fbb74cb71dcca93238
4
- data.tar.gz: 44ebe3916a714eea2f39d4fa505deaa417829d73
2
+ SHA256:
3
+ metadata.gz: 39ba496269d807186c8f30fa53c10187462c6fd3b2f6177cdfcfb7815607b09e
4
+ data.tar.gz: 5bb6db29013fc4a2cecde6de03b5ecea769cd96caf04c0216300fc8a88513ee7
5
5
  SHA512:
6
- metadata.gz: dfa5d09a294f76b210a280e66657a91ad5806b16e0f43645b31df6bff87fa062601c087c6dc2615ee0e2da3a045e52f5338a522146e63d7011b05617fa74e22e
7
- data.tar.gz: 2514368093139440cb17e6450bccceaf87486303fb1857fced53ce8c99543d9980d7f48b209afc75dc2bb948977c1063c6302505c2dd1923a7c7038e8d9b1613
6
+ metadata.gz: cb3132ffccd77d369a6b0212b8b6f47a7548fdc1e2da23bfa86a05e36e2a02eeb0fe6225875b35da4bd06478a738f156ad0c9ac3484389106fe8abeeb70acb09
7
+ data.tar.gz: f402a0c0eac7e2dc3ede2f550e33cf3f0b52034678800b8c0f9ed83cba38dcd53deae2530cef7c0e774071ce460db3ab64773fc21e25326766caf0ad4d2423de
data/README.md CHANGED
@@ -31,6 +31,9 @@ First off, open https://api.cloudflare.com/ to see all the available endpoints
31
31
  require 'rubyflare'
32
32
 
33
33
  connection = Rubyflare.connect_with('bear@dog.com', 'supersecretapikey')
34
+
35
+ # OR connect with API Token
36
+ connection = Rubyflare.connect_with_token('API_TOKEN')
34
37
  ```
35
38
 
36
39
  #### GET your user account details
@@ -79,7 +82,7 @@ First off, open https://api.cloudflare.com/ to see all the available endpoints
79
82
 
80
83
  ```
81
84
  dns_record = connection.post('zones/{#zone.result[:id]}/dns_records', {
82
- type: 'A",
85
+                               type: 'A',
83
86
  name: 'supercooldomain.com',
84
87
  content: '127.0.0.1'
85
88
  })
@@ -5,17 +5,24 @@ module Rubyflare
5
5
 
6
6
  API_URL = "https://api.cloudflare.com/client/v4/"
7
7
 
8
- def initialize(email, api_key)
9
- @email = email
10
- @api_key = api_key
8
+ def initialize(**options)
9
+ @api_token = options[:api_token]
10
+ @email = options[:email]
11
+ @api_key = options[:api_key]
12
+
11
13
  end
12
14
 
13
15
  %i(get post put patch delete).each do |method_name|
14
16
  define_method(method_name) do |endpoint, options = {}|
15
17
  options = options.to_json unless method_name == :get
16
18
  response = Curl.send(method_name, API_URL + endpoint, options) do |http|
17
- http.headers['X-Auth-Email'] = @email
18
- http.headers['X-Auth-Key'] = @api_key
19
+ # Send the Bearer request if using an API Token
20
+ unless @api_token.nil?
21
+ http.headers['Authorization'] = "Bearer " + @api_token
22
+ else
23
+ http.headers['X-Auth-Email'] = @email
24
+ http.headers['X-Auth-Key'] = @api_key
25
+ end
19
26
  http.headers['Content-Type'] = 'application/json'
20
27
  http.headers['User-Agent'] = "Rubyflare/#{Rubyflare::VERSION}"
21
28
  end
@@ -25,4 +32,3 @@ module Rubyflare
25
32
  end
26
33
  end
27
34
 
28
-
@@ -1,3 +1,3 @@
1
1
  module Rubyflare
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/rubyflare.rb CHANGED
@@ -15,6 +15,10 @@ module Rubyflare
15
15
  end
16
16
 
17
17
  def self.connect_with(email, api_key)
18
- Rubyflare::Connect.new(email, api_key)
18
+ Rubyflare::Connect.new(email: email, api_key: api_key)
19
+ end
20
+
21
+ def self.connect_with_token(api_token)
22
+ Rubyflare::Connect.new(api_token: api_token)
19
23
  end
20
24
  end
data/rubyflare.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.required_ruby_version = '>= 2.0'
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.11"
24
+ spec.add_development_dependency "bundler", "~> 2"
25
25
  spec.add_development_dependency "rake", "~> 11.3"
26
26
  spec.add_development_dependency "rspec", "~> 3.5"
27
27
  spec.add_development_dependency "webmock", "~> 2.1"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyflare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trevor Wistaff
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-18 00:00:00.000000000 Z
11
+ date: 2021-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: '2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.11'
26
+ version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ homepage: https://github.com/trev/rubyflare
122
122
  licenses:
123
123
  - MIT
124
124
  metadata: {}
125
- post_install_message:
125
+ post_install_message:
126
126
  rdoc_options: []
127
127
  require_paths:
128
128
  - lib
@@ -137,9 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  requirements: []
140
- rubyforge_project:
141
- rubygems_version: 2.5.1
142
- signing_key:
140
+ rubygems_version: 3.0.3
141
+ signing_key:
143
142
  specification_version: 4
144
143
  summary: Thin Ruby wrapper around Cloudflare's V4 API.
145
144
  test_files: []