fancyhands-ruby 1.0.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.
- data/lib/fancyhands/v1/call.rb +33 -0
- data/lib/fancyhands/v1/client.rb +66 -0
- data/lib/fancyhands/v1/custom.rb +32 -0
- data/lib/fancyhands/v1/echo.rb +15 -0
- data/lib/fancyhands/v1/message.rb +17 -0
- data/lib/fancyhands/v1/request.rb +25 -0
- data/lib/fancyhands/v1/standard.rb +32 -0
- data/lib/fancyhands.rb +9 -0
- metadata +53 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require "time"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module FancyHands
|
5
|
+
class Call
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def post(phone="", conversation={}, title="", _retry="", retry_delay="", retry_limit="")
|
11
|
+
data = {
|
12
|
+
:phone => phone,
|
13
|
+
:conversation => JSON.generate(conversation),
|
14
|
+
:title => title,
|
15
|
+
:retry => _retry,
|
16
|
+
:retry_delay => retry_delay,
|
17
|
+
:retry_limit => retry_limit,
|
18
|
+
}
|
19
|
+
return @client.request.post("call", data)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def get(key="", status="", cursor="")
|
24
|
+
data = {
|
25
|
+
:key => key,
|
26
|
+
:status => status,
|
27
|
+
:cursor => cursor
|
28
|
+
}
|
29
|
+
return @client.request.get("call", data)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require "time"
|
2
|
+
require "addressable/uri"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
require_relative 'request'
|
6
|
+
require_relative 'echo'
|
7
|
+
require_relative 'standard'
|
8
|
+
require_relative 'message'
|
9
|
+
require_relative 'custom'
|
10
|
+
require_relative 'call'
|
11
|
+
|
12
|
+
module FancyHands
|
13
|
+
module V1
|
14
|
+
class Client
|
15
|
+
|
16
|
+
attr_accessor :request
|
17
|
+
|
18
|
+
def initialize(key, secret, url="https://www.fancyhands.com/api/v1/")
|
19
|
+
@request = Request.new(key, secret, url)
|
20
|
+
@_standard = @_echo = @_custom = @_message = @_call = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
# Lazy load standard
|
24
|
+
def Standard
|
25
|
+
if !@_standard
|
26
|
+
@_standard = Standard.new(self)
|
27
|
+
end
|
28
|
+
@_standard
|
29
|
+
end
|
30
|
+
|
31
|
+
# Lazy load echo
|
32
|
+
def Echo
|
33
|
+
if !@_echo
|
34
|
+
@_echo = Echo.new(self)
|
35
|
+
end
|
36
|
+
@_echo
|
37
|
+
end
|
38
|
+
|
39
|
+
# Lazy load custom
|
40
|
+
def Custom
|
41
|
+
if !@_custom
|
42
|
+
@_custom = Custom.new(self)
|
43
|
+
end
|
44
|
+
@_custom
|
45
|
+
end
|
46
|
+
|
47
|
+
# Lazy load message
|
48
|
+
def Message
|
49
|
+
if !@_message
|
50
|
+
@_message = Message.new(self)
|
51
|
+
end
|
52
|
+
@_message
|
53
|
+
end
|
54
|
+
|
55
|
+
# Lazy load Call
|
56
|
+
def Call
|
57
|
+
if !@_call
|
58
|
+
@_call = Call.new(self)
|
59
|
+
end
|
60
|
+
@_call
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "time"
|
2
|
+
|
3
|
+
module FancyHands
|
4
|
+
class Custom
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def post(title="", description="", bid=0.0, expiration_date=nil, custom_fields={})
|
10
|
+
if !expiration_date
|
11
|
+
expiration_date = DateTime.now + 1
|
12
|
+
end
|
13
|
+
data = {
|
14
|
+
:title => title,
|
15
|
+
:description => description,
|
16
|
+
:bid => bid,
|
17
|
+
:expiration_date => expiration_date.strftime("%Y-%m-%dT%H:%M:%SZ"),
|
18
|
+
:custom_fields => custom_fields,
|
19
|
+
}
|
20
|
+
return @client.request.post("request/custom", data)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get(key="", status="", cursor="")
|
24
|
+
data = {
|
25
|
+
:key => key,
|
26
|
+
:status => status,
|
27
|
+
:cursor => cursor
|
28
|
+
}
|
29
|
+
return @client.request.get("request/custom", data)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "time"
|
2
|
+
|
3
|
+
module FancyHands
|
4
|
+
class Message
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def post(key="", message="")
|
10
|
+
data = {
|
11
|
+
:key => key,
|
12
|
+
:message => message,
|
13
|
+
}
|
14
|
+
return @client.request.post("request/standard/messages", data)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "oauth"
|
2
|
+
class Request
|
3
|
+
|
4
|
+
def initialize(key, secret, url)
|
5
|
+
@url = url
|
6
|
+
@consumer = OAuth::Consumer.new(key, secret)
|
7
|
+
end
|
8
|
+
|
9
|
+
def post(piece, data="")
|
10
|
+
response = @consumer.request(:post, @url + piece, nil, {}, data)
|
11
|
+
return JSON.parse(response.body)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(piece, data="")
|
15
|
+
if data
|
16
|
+
uri = Addressable::URI.new
|
17
|
+
uri.query_values = data
|
18
|
+
data = uri.query
|
19
|
+
end
|
20
|
+
full = @url + piece + "?" + data
|
21
|
+
response = @consumer.request(:get, full)
|
22
|
+
return JSON.parse(response.body)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "time"
|
2
|
+
|
3
|
+
module FancyHands
|
4
|
+
class Standard
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def post(title="", description="", bid=0.0, expiration_date=nil)
|
10
|
+
if !expiration_date
|
11
|
+
expiration_date = DateTime.now + 1
|
12
|
+
end
|
13
|
+
data = {
|
14
|
+
:title => title,
|
15
|
+
:description => description,
|
16
|
+
:bid => bid,
|
17
|
+
:expiration_date => expiration_date.strftime("%Y-%m-%dT%H:%M:%SZ"),
|
18
|
+
}
|
19
|
+
return @client.request.post("request/standard", data)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def get(key="", status="", cursor="")
|
24
|
+
data = {
|
25
|
+
:key => key,
|
26
|
+
:status => status,
|
27
|
+
:cursor => cursor
|
28
|
+
}
|
29
|
+
return @client.request.get("request/standard", data)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/fancyhands.rb
ADDED
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fancyhands-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ted Roden
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A ruby gem for the Fancy Hands API
|
15
|
+
email: tedroden@fancyhands.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/fancyhands.rb
|
21
|
+
- lib/fancyhands/v1/call.rb
|
22
|
+
- lib/fancyhands/v1/client.rb
|
23
|
+
- lib/fancyhands/v1/custom.rb
|
24
|
+
- lib/fancyhands/v1/echo.rb
|
25
|
+
- lib/fancyhands/v1/message.rb
|
26
|
+
- lib/fancyhands/v1/request.rb
|
27
|
+
- lib/fancyhands/v1/standard.rb
|
28
|
+
homepage: https://github.com/fancyhands/fancyhands-ruby
|
29
|
+
licenses:
|
30
|
+
- MIT
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project:
|
49
|
+
rubygems_version: 1.8.23
|
50
|
+
signing_key:
|
51
|
+
specification_version: 3
|
52
|
+
summary: Fancy Hands
|
53
|
+
test_files: []
|