godaddy-api 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a230ee5884e149472081252edc4d4005e7caab27
4
+ data.tar.gz: 8973b6bef7d05de77aa07653fce6c43a4e6fbf76
5
+ SHA512:
6
+ metadata.gz: 4a0d87b41923c36879fd841070e65c3388d41429e9a2cdaca893671957fae9f2346c4d5878470568e8f3c17860ccdbb97a623ce25aa3040418d595be5eeb85b5
7
+ data.tar.gz: e3b6367fa7befe6e3bfb7a128eecee552d5582cc429de1e29bd381b56b774c8b172e6289efb60e96dd58e0d55920ef41dc7816074e9e87cd4269e890f69a4192
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .DS_Store
11
+ .idea/
@@ -0,0 +1 @@
1
+ 2.2.2
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in godaddy-api.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Nassim Kacha
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,79 @@
1
+ # godaddy-api
2
+
3
+ [![Dependency Status](https://gemnasium.com/blueicefield/ruby-godaddy-api.svg)](https://gemnasium.com/blueicefield/ruby-godaddy-api)
4
+ [![Code Climate](https://codeclimate.com/github/blueicefield/ruby-godaddy-api/badges/gpa.svg)](https://codeclimate.com/github/blueicefield/ruby-godaddy-api)
5
+
6
+ ## Description
7
+
8
+ A very minimalist library to interact with the GoDaddy API.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'godaddy-api'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install godaddy-api
25
+
26
+ ## Usage
27
+
28
+ First, you will need to generate your API keys from [this page](https://sso.godaddy.com/login?realm=idp&app=developer&path=%2Fkeys%2F).
29
+
30
+ ```ruby
31
+ require 'godaddy/api'
32
+
33
+ api = Godaddy::Api.new apikey, apisecret
34
+
35
+ result = api.get('/v1/domains')
36
+
37
+ puts result
38
+ =>
39
+ [
40
+ {
41
+ "domainId": 11111111,
42
+ "domain": "mydomain.com",
43
+ "status": "ACTIVE",
44
+ "expires": "2016-09-14T21:59:59Z",
45
+ "expirationProtected": false,
46
+ "holdRegistrar": false,
47
+ "limited": false,
48
+ "locked": true,
49
+ "privacy": false,
50
+ "renewAuto": true,
51
+ "smart": false,
52
+ "transferProtected": false
53
+ }
54
+ ]
55
+
56
+ result = api.patch('/v1/domains/mydomain.com/records',
57
+ [{ type: 'A', name: 'test', data: '1.2.3.4', ttl: 60 }]
58
+ )
59
+
60
+ puts result
61
+ =>
62
+ {}
63
+ ```
64
+
65
+ ## Development
66
+
67
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
68
+
69
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
70
+
71
+ ## Contributing
72
+
73
+ Bug reports and pull requests are welcome on GitHub at https://github.com/blueicefield/ruby-godaddy-api.
74
+
75
+
76
+ ## License
77
+
78
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
79
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "godaddy/api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "godaddy-api"
7
+ spec.version = "0.1.0"
8
+ spec.authors = ["Nassim Kacha"]
9
+ spec.email = ["nassim.kacha@blueicefield.com"]
10
+
11
+ spec.summary = "A very minimalist library to interact with the GoDaddy API."
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/blueicefield/ruby-godaddy-api"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,43 @@
1
+ require 'net/https'
2
+ require 'json'
3
+
4
+ module Godaddy
5
+ class APIError < StandardError; end
6
+
7
+ class Api
8
+ API_URL = 'https://api.godaddy.com'
9
+
10
+ def initialize(apikey, apisecret)
11
+ @headers = {
12
+ 'Authorization' => "sso-key #{apikey}:#{apisecret}",
13
+ 'Content-type' => 'application/json'
14
+ }
15
+ end
16
+
17
+ [:get, :post, :put, :patch, :delete].each do |method|
18
+ define_method method do |uri, payload = nil|
19
+ uri = URI(API_URL + uri)
20
+ http = Net::HTTP.new(uri.host, uri.port)
21
+ http.use_ssl = true
22
+ request = build_request method, uri, payload
23
+ response = http.request(request)
24
+ result = JSON.parse(response.body)
25
+
26
+ fail APIError, result unless response.is_a?(Net::HTTPSuccess)
27
+
28
+ result
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def build_request(method, uri, payload = nil)
35
+ if payload
36
+ method == :get ? uri.query = URI.encode_www_form(payload) : body = payload.to_json
37
+ end
38
+ request = Net::HTTP.const_get(method.capitalize).new uri, @headers
39
+ request.body = body if body
40
+ request
41
+ end
42
+ end
43
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: godaddy-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nassim Kacha
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: A very minimalist library to interact with the GoDaddy API.
42
+ email:
43
+ - nassim.kacha@blueicefield.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".ruby-version"
50
+ - ".travis.yml"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/setup
57
+ - godaddy-api.gemspec
58
+ - lib/godaddy/api.rb
59
+ homepage: https://github.com/blueicefield/ruby-godaddy-api
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.4.5
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: A very minimalist library to interact with the GoDaddy API.
83
+ test_files: []