nebula_ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +59 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/nebula/client.rb +63 -0
- data/lib/nebula/token.rb +20 -0
- data/lib/nebula/version.rb +3 -0
- data/lib/nebula.rb +6 -0
- data/nebula_ruby.gemspec +39 -0
- metadata +185 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b1dcc930972917bb455e1ad62248a767dffc83ff
|
4
|
+
data.tar.gz: 3128c5ff6452646f5ba0c22faf6706597bbdbc54
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fca1265e232bfff95d45b926dbdf98a4e307e47d96b61baea2e12b29ecfea32addbc69f7bbf98f868205a71e78ceaa985a9c15e97f55e949b8f8b1a9ab844960
|
7
|
+
data.tar.gz: ee4d0aaf5354e569f80f3eabc33a817d340a2024a686843e761884f99da6cebb734f1119055e867f355ffec7f8c12a9c8bb8b72c41a23dfcd491f7727f226ecf
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Amed Rodriguez
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Nebula Ruby Gem
|
2
|
+
|
3
|
+
A Ruby wrapper for the Nebula API.
|
4
|
+
|
5
|
+
You should access the Nebula API documentation in order to learn more about the
|
6
|
+
request/response parameters for each endpoint.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
```
|
11
|
+
$ gem install nebula_ruby
|
12
|
+
```
|
13
|
+
|
14
|
+
Or if you are using Bundler, add
|
15
|
+
|
16
|
+
````
|
17
|
+
gem 'nebula_ruby'
|
18
|
+
```
|
19
|
+
|
20
|
+
## API Usage Examples
|
21
|
+
|
22
|
+
You will need to get an access token. Once you have it, initialize the client
|
23
|
+
to make authenticated calls.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'nebula'
|
27
|
+
|
28
|
+
client = Nebula::Client.new(token: '<redacted>', url: '<redacted>')
|
29
|
+
```
|
30
|
+
|
31
|
+
### Tokens
|
32
|
+
|
33
|
+
Create a token.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
attributes = {
|
37
|
+
empleado: {
|
38
|
+
noEmpleado: '123',
|
39
|
+
noEmpresa: '123',
|
40
|
+
noCodificacion: '1',
|
41
|
+
nombre: 'Sifu de la Rosa'
|
42
|
+
},
|
43
|
+
msj: 'Para una cita X'
|
44
|
+
}
|
45
|
+
|
46
|
+
token = Nebula::Token.new(client)
|
47
|
+
token.create(attributes)
|
48
|
+
```
|
49
|
+
|
50
|
+
Retrieve existing token status
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
response = token.status('X0123456')
|
54
|
+
response['status']
|
55
|
+
```
|
56
|
+
|
57
|
+
## License
|
58
|
+
|
59
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "nebula_ruby"
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
|
4
|
+
module Nebula
|
5
|
+
class Client
|
6
|
+
attr_accessor :request, :url
|
7
|
+
|
8
|
+
def initialize(options={})
|
9
|
+
@token = options[:token]
|
10
|
+
@url = options[:url]
|
11
|
+
end
|
12
|
+
|
13
|
+
def request(type, path, params={})
|
14
|
+
block = Proc.new do |request|
|
15
|
+
request.url path
|
16
|
+
request.headers['Authorization'] = "Token #{token}"
|
17
|
+
request.headers['Content-Type'] = 'application/json'
|
18
|
+
end
|
19
|
+
|
20
|
+
send("#{type}_request", path, params, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def put_request(path, params={}, &block)
|
25
|
+
connection.put do |request|
|
26
|
+
yield(request)
|
27
|
+
request.body = params.to_json
|
28
|
+
end
|
29
|
+
.body
|
30
|
+
end
|
31
|
+
|
32
|
+
def post_request(path, params={}, &block)
|
33
|
+
connection.post do |request|
|
34
|
+
yield(request)
|
35
|
+
request.body = params.to_json
|
36
|
+
end
|
37
|
+
.body
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_request(path, params={}, &block)
|
41
|
+
connection.get do |request|
|
42
|
+
yield(request)
|
43
|
+
params.each { |key, val| request.params[key] = val }
|
44
|
+
end
|
45
|
+
.body
|
46
|
+
end
|
47
|
+
|
48
|
+
def token
|
49
|
+
@token
|
50
|
+
end
|
51
|
+
|
52
|
+
def url
|
53
|
+
@url
|
54
|
+
end
|
55
|
+
|
56
|
+
def connection
|
57
|
+
@connection ||= Faraday.new(url: url) do |b|
|
58
|
+
b.adapter Faraday.default_adapter
|
59
|
+
b.use FaradayMiddleware::ParseJson
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/nebula/token.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Nebula
|
2
|
+
class Token
|
3
|
+
def initialize(client)
|
4
|
+
@client = client
|
5
|
+
end
|
6
|
+
|
7
|
+
def create(params)
|
8
|
+
client.request(:post, '/Nebula/rest/token/new', params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def status(token)
|
12
|
+
client.request(:get, "/Nebula/rest/token/status/#{token}")
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def client
|
17
|
+
@client
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/nebula.rb
ADDED
data/nebula_ruby.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'nebula/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "nebula_ruby"
|
8
|
+
spec.version = Nebula::VERSION
|
9
|
+
spec.authors = ["Amed Rodriguez"]
|
10
|
+
spec.email = ["amed.rdz@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Nebula API Ruby Wrapper}
|
13
|
+
spec.homepage = "https://github.com/amedrz/cumulus_ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec"
|
32
|
+
spec.add_development_dependency "webmock"
|
33
|
+
spec.add_development_dependency "vcr"
|
34
|
+
spec.add_development_dependency "pry"
|
35
|
+
|
36
|
+
spec.add_dependency "faraday"
|
37
|
+
spec.add_dependency "faraday_middleware"
|
38
|
+
spec.add_dependency "json"
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nebula_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Amed Rodriguez
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-07 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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: vcr
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: faraday
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: faraday_middleware
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: json
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description:
|
140
|
+
email:
|
141
|
+
- amed.rdz@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".gitignore"
|
147
|
+
- ".travis.yml"
|
148
|
+
- CODE_OF_CONDUCT.md
|
149
|
+
- Gemfile
|
150
|
+
- LICENSE.txt
|
151
|
+
- README.md
|
152
|
+
- Rakefile
|
153
|
+
- bin/console
|
154
|
+
- bin/setup
|
155
|
+
- lib/nebula.rb
|
156
|
+
- lib/nebula/client.rb
|
157
|
+
- lib/nebula/token.rb
|
158
|
+
- lib/nebula/version.rb
|
159
|
+
- nebula_ruby.gemspec
|
160
|
+
homepage: https://github.com/amedrz/cumulus_ruby
|
161
|
+
licenses:
|
162
|
+
- MIT
|
163
|
+
metadata:
|
164
|
+
allowed_push_host: https://rubygems.org
|
165
|
+
post_install_message:
|
166
|
+
rdoc_options: []
|
167
|
+
require_paths:
|
168
|
+
- lib
|
169
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
requirements: []
|
180
|
+
rubyforge_project:
|
181
|
+
rubygems_version: 2.4.5
|
182
|
+
signing_key:
|
183
|
+
specification_version: 4
|
184
|
+
summary: Nebula API Ruby Wrapper
|
185
|
+
test_files: []
|