rapid_connect 0.0.1.1
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.
- checksums.yaml +7 -0
- data/lib/rapid_connect/request.rb +32 -0
- data/lib/rapid_connect.rb +36 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: abe55a9cf5214254f89e8eeb183dcab25536c8eb
|
4
|
+
data.tar.gz: cd4073d846a25530f0c11853445a69f12be43209
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 730b969f5bc4537fa844bde6934822fdead9704e83aee07aede05021a9fc89dbeba59b394a3d7ac0426f58af3400d2fdf0b9808e1d769dfe0f15ee45213db5f5
|
7
|
+
data.tar.gz: a51ce92f4cf228aab9cd482b3341f76af69960ab62b0fbf425ca8dbe1ab9ae9babc4e499533ea0a3334b2214cf067c2ac37294f47f5aefefcc41dfff09c975c0
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class RapidConnect::Request
|
5
|
+
|
6
|
+
def initialize project, token
|
7
|
+
@project = project
|
8
|
+
@token = token
|
9
|
+
end
|
10
|
+
|
11
|
+
def url pack, block
|
12
|
+
File.join('https://rapidapi.io/connect', File.join(pack, block))
|
13
|
+
end
|
14
|
+
|
15
|
+
def request pack, block, args
|
16
|
+
@resp = false
|
17
|
+
@args = args
|
18
|
+
uri = URI.parse(url(pack, block))
|
19
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
20
|
+
req = Net::HTTP::Post.new(uri.path)
|
21
|
+
req.basic_auth @project, @token
|
22
|
+
req.set_form_data(@args)
|
23
|
+
@resp = http.request(req)
|
24
|
+
end
|
25
|
+
if @resp.is_a?(Net::HTTPSuccess)
|
26
|
+
data = JSON.parse @resp.body
|
27
|
+
return data
|
28
|
+
end
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class RapidConnect
|
2
|
+
|
3
|
+
def initialize project = false, token = false
|
4
|
+
@project = project
|
5
|
+
@token = token
|
6
|
+
end
|
7
|
+
|
8
|
+
def load_config file
|
9
|
+
config = YAML::load(File.open(file))
|
10
|
+
@project = config['rapid_connect']['project'] if config['rapid_connect'] && config['rapid_connect']['project']
|
11
|
+
@token = config['rapid_connect']['token'] if config['rapid_connect'] && config['rapid_connect']['token']
|
12
|
+
end
|
13
|
+
|
14
|
+
def project
|
15
|
+
@project
|
16
|
+
end
|
17
|
+
|
18
|
+
def token
|
19
|
+
@token
|
20
|
+
end
|
21
|
+
|
22
|
+
def call pack, block, args = {}
|
23
|
+
if @project && @token
|
24
|
+
@request = Request.new(@project, @token)
|
25
|
+
response = @request.request(pack, block, args)
|
26
|
+
return response if response
|
27
|
+
end
|
28
|
+
return {
|
29
|
+
'outcome' => 'error',
|
30
|
+
'msg' => 'connection error'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
require './lib/rapid_connect/request'
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rapid_connect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Frank Cieslik
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Use RapidAPI blocks from your Ruby app
|
14
|
+
email: frank.cieslik@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/rapid_connect.rb
|
20
|
+
- lib/rapid_connect/request.rb
|
21
|
+
homepage: https://github.com/fraank/RapidAPIConnect_Ruby
|
22
|
+
licenses:
|
23
|
+
- Apache License
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.4.6
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: RapidAPIConnect_Ruby
|
45
|
+
test_files: []
|