fancyhands-ruby 1.0.0 → 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 99b77bd3b1c7bcf10800ea2f9cd095205b590741
4
+ data.tar.gz: d14641b967436253400bbfe72c49574d67c83417
5
+ SHA512:
6
+ metadata.gz: 471c4e45629cd4ca4207a8ffda5d0ebbf401fdc9b767e190ea67d3538cca894768d5acbd775e22bf7d3a3a1ea6eb086df916babd3ebcef0b8eeb5223edf52f02
7
+ data.tar.gz: 2f009daaac36a0ab4305f360ad385e1a1b1abb7f4495a9955b2e3d663511caec4a8f521d7061b3747617bfd9ae411c9bd10a3a7f9a87f92a5207ab370004a3f7
@@ -7,7 +7,10 @@ require_relative 'echo'
7
7
  require_relative 'standard'
8
8
  require_relative 'message'
9
9
  require_relative 'custom'
10
- require_relative 'call'
10
+ require_relative 'outgoing'
11
+ require_relative 'history'
12
+ require_relative 'incoming'
13
+ require_relative 'number'
11
14
 
12
15
  module FancyHands
13
16
  module V1
@@ -17,7 +20,7 @@ module FancyHands
17
20
 
18
21
  def initialize(key, secret, url="https://www.fancyhands.com/api/v1/")
19
22
  @request = Request.new(key, secret, url)
20
- @_standard = @_echo = @_custom = @_message = @_call = nil
23
+ @_standard = @_echo = @_custom = @_message = @_outgoing = @_incoming = @_number = @_history = nil
21
24
  end
22
25
 
23
26
  # Lazy load standard
@@ -52,12 +55,36 @@ module FancyHands
52
55
  @_message
53
56
  end
54
57
 
55
- # Lazy load Call
56
- def Call
57
- if !@_call
58
- @_call = Call.new(self)
58
+ # Lazy load Outgoing
59
+ def Outgoing
60
+ if !@_outgoing
61
+ @_outgoing = Outgoing.new(self)
59
62
  end
60
- @_call
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
61
88
  end
62
89
 
63
90
  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,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,42 @@
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
+
32
+ def get(key="", status="", cursor="")
33
+ data = {
34
+ :key => key,
35
+ :status => status,
36
+ :cursor => cursor
37
+ }
38
+ return @client.request.get("call/outgoing", data)
39
+ end
40
+
41
+ end
42
+ end
@@ -11,6 +11,23 @@ class Request
11
11
  return JSON.parse(response.body)
12
12
  end
13
13
 
14
+ def delete(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(:delete, full)
22
+ return JSON.parse(response.body)
23
+ end
24
+
25
+ def put(piece, data="")
26
+ # {'Content-Type' => 'application/x-www-form-urlencoded'}
27
+ response = @consumer.request(:put, @url + piece, nil, {}, data)
28
+ return JSON.parse(response.body)
29
+ end
30
+
14
31
  def get(piece, data="")
15
32
  if data
16
33
  uri = Addressable::URI.new
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fancyhands-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ted Roden
8
+ - Nick Mercer
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-26 00:00:00.000000000 Z
12
+ date: 2014-11-12 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A ruby gem for the Fancy Hands API
15
15
  email: tedroden@fancyhands.com
@@ -18,36 +18,38 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - lib/fancyhands.rb
21
- - lib/fancyhands/v1/call.rb
22
21
  - lib/fancyhands/v1/client.rb
23
22
  - lib/fancyhands/v1/custom.rb
24
23
  - lib/fancyhands/v1/echo.rb
24
+ - lib/fancyhands/v1/history.rb
25
+ - lib/fancyhands/v1/incoming.rb
25
26
  - lib/fancyhands/v1/message.rb
27
+ - lib/fancyhands/v1/number.rb
28
+ - lib/fancyhands/v1/outgoing.rb
26
29
  - lib/fancyhands/v1/request.rb
27
30
  - lib/fancyhands/v1/standard.rb
28
31
  homepage: https://github.com/fancyhands/fancyhands-ruby
29
32
  licenses:
30
33
  - MIT
34
+ metadata: {}
31
35
  post_install_message:
32
36
  rdoc_options: []
33
37
  require_paths:
34
38
  - lib
35
39
  required_ruby_version: !ruby/object:Gem::Requirement
36
- none: false
37
40
  requirements:
38
- - - ! '>='
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: '0'
41
44
  required_rubygems_version: !ruby/object:Gem::Requirement
42
- none: false
43
45
  requirements:
44
- - - ! '>='
46
+ - - ">="
45
47
  - !ruby/object:Gem::Version
46
48
  version: '0'
47
49
  requirements: []
48
50
  rubyforge_project:
49
- rubygems_version: 1.8.23
51
+ rubygems_version: 2.2.2
50
52
  signing_key:
51
- specification_version: 3
53
+ specification_version: 4
52
54
  summary: Fancy Hands
53
55
  test_files: []
@@ -1,33 +0,0 @@
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