task_master-fancyhands-ruby 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9a2a20c26778359d6a2bc5ad79b9c06ee5d6ede8
4
+ data.tar.gz: 61d47c12a79800d665cef01dfb1b0f04f09a3679
5
+ SHA512:
6
+ metadata.gz: 5c56893622f72c52e757e2039870c89a2f51908c3484ecc60d0d34d52d26a10ec4ee052ca7f24c783c4b1f2f18c0713f226f50c8a731efcfc85b5f63035f4cc9
7
+ data.tar.gz: d2cbdd320dda999213df9d054cb6ba6b1aa8a9655930b9670b1e8bac835411f669573c154a1e404854abe48ee99d6f25cccb359a1601f45b7370bda1763d2c6e
@@ -0,0 +1,9 @@
1
+ require 'forwardable'
2
+
3
+ require_relative 'fancyhands/v1/client'
4
+
5
+ module FancyHands
6
+ extend SingleForwardable
7
+ def_delegators :key, :secret, :url
8
+
9
+ end
@@ -0,0 +1,93 @@
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 'outgoing'
11
+ require_relative 'history'
12
+ require_relative 'incoming'
13
+ require_relative 'number'
14
+
15
+ module FancyHands
16
+ module V1
17
+ class Client
18
+
19
+ attr_accessor :request
20
+
21
+ def initialize(key, secret, url="https://www.fancyhands.com/api/v1/")
22
+ @request = Request.new(key, secret, url)
23
+ @_standard = @_echo = @_custom = @_message = @_outgoing = @_incoming = @_number = @_history = nil
24
+ end
25
+
26
+ # Lazy load standard
27
+ def Standard
28
+ if !@_standard
29
+ @_standard = Standard.new(self)
30
+ end
31
+ @_standard
32
+ end
33
+
34
+ # Lazy load echo
35
+ def Echo
36
+ if !@_echo
37
+ @_echo = Echo.new(self)
38
+ end
39
+ @_echo
40
+ end
41
+
42
+ # Lazy load custom
43
+ def Custom
44
+ if !@_custom
45
+ @_custom = Custom.new(self)
46
+ end
47
+ @_custom
48
+ end
49
+
50
+ # Lazy load message
51
+ def Message
52
+ if !@_message
53
+ @_message = Message.new(self)
54
+ end
55
+ @_message
56
+ end
57
+
58
+ # Lazy load Outgoing
59
+ def Outgoing
60
+ if !@_outgoing
61
+ @_outgoing = Outgoing.new(self)
62
+ end
63
+ @_outgoing
64
+ end
65
+
66
+ # Lazy load Incoming
67
+ def Incoming
68
+ if !@_incoming
69
+ @_incoming = Incoming.new(self)
70
+ end
71
+ @_incoming
72
+ end
73
+
74
+ # Lazy load Number
75
+ def Number
76
+ if !@_number
77
+ @_number = Number.new(self)
78
+ end
79
+ @_number
80
+ end
81
+
82
+ # Lazy load History
83
+ def History
84
+ if !@_history
85
+ @_history = History.new(self)
86
+ end
87
+ @_history
88
+ end
89
+
90
+ end
91
+ end
92
+ end
93
+
@@ -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,15 @@
1
+ module FancyHands
2
+ class Echo
3
+ def initialize(client)
4
+ @client = client
5
+ end
6
+
7
+ def post(data)
8
+ return @client.request.post("echo", data)
9
+ end
10
+
11
+ def get(data)
12
+ return @client.request.get("echo", data)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ require "time"
2
+ require "json"
3
+
4
+ module FancyHands
5
+ class History
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ def get(key="", phone_number="", cursor="")
11
+ data = {
12
+ :key => key,
13
+ :phone_number => phone_number,
14
+ :cursor => cursor
15
+ }
16
+ return @client.request.get("call/history", data)
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,44 @@
1
+ require "time"
2
+ require "json"
3
+
4
+ module FancyHands
5
+ class Incoming
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ def post(phone_number="", conversation={})
11
+ data = {
12
+ :phone_number => phone_number,
13
+ :conversation => JSON.generate(conversation)
14
+ }
15
+ return @client.request.post("call/incoming", data)
16
+ end
17
+
18
+ def get(phone_number="", key="", cursor="")
19
+ data = {
20
+ :phone_number => phone_number,
21
+ :key => key,
22
+ :cursor => cursor
23
+ }
24
+ return @client.request.get("call/incoming", data)
25
+ end
26
+
27
+ def put(phone_number=nil, key=nil, conversation={})
28
+ data = {
29
+ :phone_number => phone_number,
30
+ :conversation => JSON.generate(conversation)
31
+ }
32
+ return @client.request.put("call/incoming", data)
33
+ end
34
+
35
+ def delete(phone_number='', key='')
36
+ data = {
37
+ :phone_number => phone_number,
38
+ :key => key
39
+ }
40
+ return @client.request.delete("call/incoming", data)
41
+ end
42
+
43
+ end
44
+ 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,35 @@
1
+ require "time"
2
+ require "json"
3
+
4
+ module FancyHands
5
+ class Number
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ def post(phone_number="")
11
+ data = {
12
+ :phone_number => phone_number
13
+ }
14
+ return @client.request.post("call/number", data)
15
+ end
16
+
17
+ def get(area_code=nil, contains=nil, region=nil)
18
+ data = {
19
+ :area_code => area_code,
20
+ :contains => contains,
21
+ :region => region
22
+ }
23
+ return @client.request.get("call/number", data)
24
+ end
25
+
26
+ def delete(phone_number=nil, key=nil)
27
+ data = {
28
+ :phone_number => phone_number,
29
+ :key => key
30
+ }
31
+ return @client.request.delete("call/number", data)
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,41 @@
1
+ require "time"
2
+ require "json"
3
+
4
+ module FancyHands
5
+ class Outgoing
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ def post(phone="", conversation={}, title="", record="", _retry="", retry_delay="", retry_limit="", call_window_start=nil, call_window_end=nil, timeout=nil, voicemail=false)
11
+ data = {
12
+ :phone => phone,
13
+ :conversation => JSON.generate(conversation),
14
+ :title => title,
15
+ :record => record,
16
+ :retry => _retry,
17
+ :retry_delay => retry_delay,
18
+ :retry_limit => retry_limit,
19
+ :timeout => timeout,
20
+ :voicemail => voicemail,
21
+ }
22
+
23
+ if call_window_start and call_window_end
24
+ data[:call_window_start] = call_window_start.strftime("%Y-%m-%dT%H:%M:%SZ")
25
+ data[:call_window_end] = call_window_end.strftime("%Y-%m-%dT%H:%M:%SZ")
26
+ end
27
+
28
+ return @client.request.post("call/outgoing", data)
29
+ end
30
+
31
+ def get(key="", status="", cursor="")
32
+ data = {
33
+ :key => key,
34
+ :status => status,
35
+ :cursor => cursor
36
+ }
37
+ return @client.request.get("call/outgoing", data)
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,44 @@
1
+ require "oauth"
2
+ module FancyHands
3
+ class Request
4
+
5
+ def initialize(key, secret, url)
6
+ @url = url
7
+ @consumer = OAuth::Consumer.new(key, secret)
8
+ end
9
+
10
+ def post(piece, data="")
11
+ response = @consumer.request(:post, @url + piece, nil, {}, data)
12
+ return JSON.parse(response.body)
13
+ end
14
+
15
+ def delete(piece, data="")
16
+ if data
17
+ uri = Addressable::URI.new
18
+ uri.query_values = data
19
+ data = uri.query
20
+ end
21
+ full = @url + piece + "?" + data
22
+ response = @consumer.request(:delete, full)
23
+ return JSON.parse(response.body)
24
+ end
25
+
26
+ def put(piece, data="")
27
+ # {'Content-Type' => 'application/x-www-form-urlencoded'}
28
+ response = @consumer.request(:put, @url + piece, nil, {}, data)
29
+ return JSON.parse(response.body)
30
+ end
31
+
32
+ def get(piece, data="")
33
+ if data
34
+ uri = Addressable::URI.new
35
+ uri.query_values = data
36
+ data = uri.query
37
+ end
38
+ full = @url + piece + "?" + data
39
+ response = @consumer.request(:get, full)
40
+ return JSON.parse(response.body)
41
+ end
42
+
43
+ end
44
+ 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
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: task_master-fancyhands-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sean Devine
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: oauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: addressable
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A fork of the official ruby gem for the Fancy Hands API
42
+ email: barelyknown@icloud.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/fancyhands.rb
48
+ - lib/fancyhands/v1/client.rb
49
+ - lib/fancyhands/v1/custom.rb
50
+ - lib/fancyhands/v1/echo.rb
51
+ - lib/fancyhands/v1/history.rb
52
+ - lib/fancyhands/v1/incoming.rb
53
+ - lib/fancyhands/v1/message.rb
54
+ - lib/fancyhands/v1/number.rb
55
+ - lib/fancyhands/v1/outgoing.rb
56
+ - lib/fancyhands/v1/request.rb
57
+ - lib/fancyhands/v1/standard.rb
58
+ homepage: https://github.com/togglepro/task_master-fancyhands-ruby
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.4.5
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Fancy Hands
82
+ test_files: []
83
+ has_rdoc: