phoneburner 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aef0746c59c3d487aa6317db81fb8a30ba3d230e
4
- data.tar.gz: 76c2dbd61bb6f9c5c55c02cc5750e93418bd857a
3
+ metadata.gz: cbbb3200084bf2f88d4e0b1d5adc83239c529097
4
+ data.tar.gz: 1ff8c9165c462cd4f38fe3620900d38c2fb02af9
5
5
  SHA512:
6
- metadata.gz: b37664120c576d7cc78a006eaa9c35c41779d97996f320eda7ab6b70d61e530b7a65a77804e28ed90946f7e853347b3788dbbb598e555534c29cc2fc99416946
7
- data.tar.gz: b850783cf6d8cfc86e36e9abd337cf3cd43d4e05281f3326c35ce9d3c3dcc99d87c22e6ade0c84c75bff57936c5c2c10455a58ab42a2d2c9ef5e4001cc2aec7a
6
+ metadata.gz: 361e03930c94cf3cef78645f6dc31cf7e62e5019a74304c36233b61647496a421fff6217620d60fff1be2cfedf7a13606609e54790abd33646caa0fd2db18a2f
7
+ data.tar.gz: 664f656f1ab4d6af88a72edb9c0a10d802b15ead79cc0b0397fda2e6a55ce072ca88a723bd5a5d0b0adf9c7affbcf0395e7482a96ea30387e3d7115c7fc9d9e0
data/lib/phoneburner.rb CHANGED
@@ -10,14 +10,15 @@ require "phoneburner/dialsession"
10
10
  require "phoneburner/folder"
11
11
  require "phoneburner/settings"
12
12
  require "phoneburner/voicemail"
13
+ require "phoneburner/call"
13
14
 
14
15
 
15
16
  require "rest-client"
16
17
 
17
18
  module Phoneburner
18
19
 
19
- def self.client(api_token)
20
- Phoneburner::Client.new(api_token)
20
+ def self.client(api_token,opts={})
21
+ Phoneburner::Client.new(api_token,opts)
21
22
  end
22
23
 
23
24
  end
@@ -1,10 +1,12 @@
1
1
  module Phoneburner
2
2
  class Client
3
3
 
4
- attr_accessor :token
4
+ attr_accessor :token, :url
5
5
 
6
- def initialize(token)
6
+ def initialize(token, opts={})
7
7
  @token = token
8
+ @url = opts[:url]
9
+ @url ||= "https://www.phoneburner.com"
8
10
  end
9
11
 
10
12
  def contacts
@@ -17,5 +17,15 @@ module Phoneburner
17
17
  self.user_id = i
18
18
  end
19
19
 
20
+ def self.extract_inner_results(results, request)
21
+ r = super(results,request)
22
+ if r.is_a?(Array)
23
+ if r.first.is_a?(Array)
24
+ r = r.flatten
25
+ end
26
+ end
27
+ r
28
+ end
29
+
20
30
  end
21
31
  end
@@ -2,14 +2,14 @@ module Phoneburner
2
2
  class Model
3
3
 
4
4
  def initialize(client, attrs={})
5
- @client = client
5
+ @client = client
6
6
  attributes(attrs)
7
7
  end
8
8
 
9
9
  def attributes(attrs)
10
- @attrs = Hash[attrs.map do |k, v|
10
+ @attrs = Hash[attrs.map do |k, v|
11
11
  if v.is_a?(Hash)
12
- [k.to_s, Phoneburner::Model.new(client,v)]
12
+ [k.to_s, Phoneburner::Model.new(@client,v)]
13
13
  else
14
14
  [k.to_s, v]
15
15
  end
@@ -42,6 +42,7 @@ module Phoneburner
42
42
  end
43
43
 
44
44
  def method_missing(symbol,*args)
45
+ @attrs ||= {}
45
46
  if symbol.to_s.end_with?("=")
46
47
  @attrs[symbol.to_s.gsub!(/=$/,'')] = args.first
47
48
  else
@@ -49,8 +50,8 @@ module Phoneburner
49
50
  end
50
51
  end
51
52
 
52
- def to_json
53
- @attrs.to_json
53
+ def to_json(a=nil)
54
+ @attrs.to_json(a)
54
55
  end
55
56
 
56
57
  def is_new?
@@ -87,7 +88,7 @@ module Phoneburner
87
88
  private
88
89
  def update_attributes(attrs)
89
90
  attrs.each do |k, v|
90
- @attrs[k.to_s] = v.is_a?(Hash) ? Phoneburner::Model.new(client,v)] : v
91
+ @attrs[k.to_s] = v.is_a?(Hash) ? Phoneburner::Model.new(client,v) : v
91
92
  end
92
93
  nil
93
94
  end
@@ -5,7 +5,7 @@ module Phoneburner
5
5
  @model = model
6
6
  @client = client
7
7
  @token = client.token
8
- @url = "https://www.phoneburner.com"
8
+ @url = client.url
9
9
  @query_params = {}
10
10
  end
11
11
 
@@ -46,6 +46,12 @@ module Phoneburner
46
46
  end
47
47
  end
48
48
 
49
+ def create!(obj_or_hash_or_json)
50
+ Phoneburner::Response.new(self) do
51
+ RestClient.post "#{@url}#{@model.path}", as_json(obj_or_hash_or_json), {:Authorization => "Bearer #{@token}",:content_type => :json, :accept => :json}
52
+ end.result
53
+ end
54
+
49
55
  def update(id,obj_or_hash_or_json)
50
56
  Phoneburner::Response.new(self) do
51
57
  RestClient.put "#{@url}#{@model.path}#{id}", as_json(obj_or_hash_or_json), {:Authorization => "Bearer #{@token}",:content_type => :json, :accept => :json}
@@ -66,7 +66,8 @@ module Phoneburner
66
66
  parse()
67
67
  return nil if @inner_results.nil?
68
68
  if @inner_results.is_a?(Array)
69
- e = Enumerator.new do |y|
69
+ puts "Array"
70
+ e = Enumerator.new do |y|
70
71
  @inner_results.each do |ir|
71
72
  obj = is_raw? ? ir : request.build(ir)
72
73
  y.yield(obj)
@@ -1,3 +1,3 @@
1
1
  module Phoneburner
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/phoneburner.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["dennis@rigpasolutions.com"]
11
11
  spec.summary = %q{API for PhoneBurner.com}
12
12
  spec.description = %q{API for PhoneBurner.com}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/dennis27/phoneburner"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phoneburner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Vaughn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-06 00:00:00.000000000 Z
11
+ date: 2015-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -79,7 +79,7 @@ files:
79
79
  - lib/phoneburner/version.rb
80
80
  - lib/phoneburner/voicemail.rb
81
81
  - phoneburner.gemspec
82
- homepage: ''
82
+ homepage: https://github.com/dennis27/phoneburner
83
83
  licenses:
84
84
  - MIT
85
85
  metadata: {}