bvr 0.0.1 → 0.1.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.
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: bvr
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.1.0
6
6
  platform: ruby
7
7
  authors:
8
- - gregory
8
+ - Gregory Horion
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-27 00:00:00.000000000 Z
12
+ date: 2013-12-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,66 +30,66 @@ dependencies:
30
30
  - !ruby/object:Gem::Dependency
31
31
  version_requirements: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - ! '>='
33
+ - - ~>
34
34
  - !ruby/object:Gem::Version
35
- version: '0'
35
+ version: 10.1.1
36
36
  none: false
37
37
  name: rake
38
38
  type: :development
39
39
  prerelease: false
40
40
  requirement: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - ! '>='
42
+ - - ~>
43
43
  - !ruby/object:Gem::Version
44
- version: '0'
44
+ version: 10.1.1
45
45
  none: false
46
46
  - !ruby/object:Gem::Dependency
47
47
  version_requirements: !ruby/object:Gem::Requirement
48
48
  requirements:
49
- - - ! '>='
49
+ - - ~>
50
50
  - !ruby/object:Gem::Version
51
- version: '0'
51
+ version: 1.5.2
52
52
  none: false
53
53
  name: rack
54
54
  type: :development
55
55
  prerelease: false
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ! '>='
58
+ - - ~>
59
59
  - !ruby/object:Gem::Version
60
- version: '0'
60
+ version: 1.5.2
61
61
  none: false
62
62
  - !ruby/object:Gem::Dependency
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ! '>='
65
+ - - ~>
66
66
  - !ruby/object:Gem::Version
67
- version: '0'
67
+ version: 0.8.8
68
68
  none: false
69
69
  name: faraday
70
70
  type: :development
71
71
  prerelease: false
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ! '>='
74
+ - - ~>
75
75
  - !ruby/object:Gem::Version
76
- version: '0'
76
+ version: 0.8.8
77
77
  none: false
78
78
  - !ruby/object:Gem::Dependency
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ! '>='
81
+ - - ~>
82
82
  - !ruby/object:Gem::Version
83
- version: '0'
83
+ version: 1.1.3
84
84
  none: false
85
- name: happymapper
85
+ name: xml-simple
86
86
  type: :development
87
87
  prerelease: false
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - ! '>='
90
+ - - ~>
91
91
  - !ruby/object:Gem::Version
92
- version: '0'
92
+ version: 1.1.3
93
93
  none: false
94
94
  description: A ruby interface to Bestvoipreselling API
95
95
  email:
@@ -99,6 +99,7 @@ extensions: []
99
99
  extra_rdoc_files: []
100
100
  files:
101
101
  - .gitignore
102
+ - CHANGELOG.md
102
103
  - Gemfile
103
104
  - Guardfile
104
105
  - LICENSE.txt
@@ -107,18 +108,34 @@ files:
107
108
  - bvr.gemspec
108
109
  - lib/bvr.rb
109
110
  - lib/bvr/call.rb
110
- - lib/bvr/call_overview.rb
111
+ - lib/bvr/call_collection.rb
111
112
  - lib/bvr/configuration.rb
112
113
  - lib/bvr/connection.rb
114
+ - lib/bvr/credit.rb
115
+ - lib/bvr/customer.rb
113
116
  - lib/bvr/phone.rb
117
+ - lib/bvr/phone_collection.rb
114
118
  - lib/bvr/version.rb
115
119
  - spec/fixtures/CallOverview.xml
116
- - spec/lib/bvr/call_overview_spec.rb
120
+ - spec/fixtures/changepassword.xml
121
+ - spec/fixtures/changeuserinfo.xml
122
+ - spec/fixtures/createcustomer_response.xml
123
+ - spec/fixtures/customerblocked.xml
124
+ - spec/fixtures/getuserinfo.xml
125
+ - spec/fixtures/settransaction.xml
126
+ - spec/fixtures/settransaction_failed.xml
127
+ - spec/fixtures/validateuser.xml
128
+ - spec/helpers/faraday_stub.rb
129
+ - spec/lib/bvr/call_collection_spec.rb
130
+ - spec/lib/bvr/call_spec.rb
117
131
  - spec/lib/bvr/configuration_spec.rb
118
132
  - spec/lib/bvr/connection_spec.rb
133
+ - spec/lib/bvr/credit_spec.rb
134
+ - spec/lib/bvr/customer_spec.rb
135
+ - spec/lib/bvr/phone_collection_spec.rb
119
136
  - spec/lib/bvr_spec.rb
120
137
  - spec/spec_helper.rb
121
- homepage: ''
138
+ homepage: https://github.com/gregory/bvr
122
139
  licenses:
123
140
  - MIT
124
141
  post_install_message:
@@ -145,9 +162,22 @@ specification_version: 3
145
162
  summary: A ruby interface to Bestvoipreselling API
146
163
  test_files:
147
164
  - spec/fixtures/CallOverview.xml
148
- - spec/lib/bvr/call_overview_spec.rb
165
+ - spec/fixtures/changepassword.xml
166
+ - spec/fixtures/changeuserinfo.xml
167
+ - spec/fixtures/createcustomer_response.xml
168
+ - spec/fixtures/customerblocked.xml
169
+ - spec/fixtures/getuserinfo.xml
170
+ - spec/fixtures/settransaction.xml
171
+ - spec/fixtures/settransaction_failed.xml
172
+ - spec/fixtures/validateuser.xml
173
+ - spec/helpers/faraday_stub.rb
174
+ - spec/lib/bvr/call_collection_spec.rb
175
+ - spec/lib/bvr/call_spec.rb
149
176
  - spec/lib/bvr/configuration_spec.rb
150
177
  - spec/lib/bvr/connection_spec.rb
178
+ - spec/lib/bvr/credit_spec.rb
179
+ - spec/lib/bvr/customer_spec.rb
180
+ - spec/lib/bvr/phone_collection_spec.rb
151
181
  - spec/lib/bvr_spec.rb
152
182
  - spec/spec_helper.rb
153
183
  has_rdoc:
@@ -1,46 +0,0 @@
1
- require_relative 'call'
2
- module Bvr
3
- class CallOverview
4
- API_COMMAND = 'CallOverview'
5
- # Valid Options:
6
- # Variable Value Option Description
7
- # command calloverview Mandatory
8
- # username X..140 Mandatory the username of the reseller
9
- # password X..100 Mandatory the password of the reseller
10
- # customer X..140 Mandatory the username of the customer
11
- # date YYYY-MM-DD hh:nn:ss Optional the datetime from which to start retrieving the history, current datetime is default
12
- # callid N..1000000 Optional the callid from which to start retrieving the history, 0 is default
13
- # recordcount 1 - 500 Optional the maximum number of records returned, 10 is default, 500 is maximum
14
- # direction forward / backward Optional the direction to search, backward is default
15
- VALID_OPTIONS = [:date, :callid, :recordcount, :direction]
16
-
17
- include ::HappyMapper
18
-
19
- tag 'Calls'
20
- has_many :calls, Bvr::Call
21
- attribute :count, Integer, tag: 'Count'
22
-
23
-
24
- def self.find(customer_id, options={})
25
- raise ArgumentError.new('Unknown Argument') unless self.valid_options?(options)
26
-
27
- params = {
28
- command: API_COMMAND,
29
- customer: customer_id
30
- }
31
-
32
- options.merge! params
33
- self.parse(self.result(options)).first #only one <Calls> tag
34
- end
35
-
36
- private
37
-
38
- def self.result(options)
39
- Bvr.connection.get(options)
40
- end
41
-
42
- def self.valid_options?(options)
43
- options.empty? ? true : options.keys.all? { |option| VALID_OPTIONS.include? option}
44
- end
45
- end
46
- end
@@ -1,94 +0,0 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe Bvr::CallOverview do
4
- describe '.find(customer_id, options)' do
5
- let(:customer_id) { 'john' }
6
- let(:connection) { Minitest::Mock.new }
7
- let(:body) { 'response' }
8
-
9
- def stub_connection
10
- Bvr.stub(:connection, connection) { yield }
11
- end
12
-
13
- def stub_result(res)
14
- Bvr::CallOverview.stub(:result, res) { yield }
15
- end
16
-
17
- def stub_parse(result)
18
- Bvr::CallOverview.stub(:parse, result) { yield }
19
- end
20
-
21
- describe 'when options are omitted' do
22
- subject{ Bvr::CallOverview.find(customer_id) }
23
-
24
- it 'sets the right command and the customer_id' do
25
- stub_connection do
26
- stub_parse([]) do
27
- connection.expect :get, [], [{command: Bvr::CallOverview::API_COMMAND, customer: customer_id}]
28
- subject
29
- connection.verify
30
- end
31
- end
32
- end
33
- end
34
-
35
- describe 'when options are provided, it merges the options with the command and customer_id' do
36
- let(:options) { { recordcount: 'bar', callid: 'foo' } }
37
-
38
- subject{ Bvr::CallOverview.find(customer_id, options) }
39
-
40
- it 'merges the CallOverview command and the customer_id with options' do
41
- stub_connection do
42
- stub_parse([]) do
43
- expected_options = options.merge({command: Bvr::CallOverview::API_COMMAND, customer: customer_id})
44
- connection.expect :get, [], [expected_options]
45
- subject
46
- connection.verify
47
- end
48
- end
49
- end
50
- end
51
-
52
- describe 'when wrong options are provided, raise an argument error' do
53
- let(:options) { { foo: 'bar', john: 'Doe' } }
54
-
55
- subject{ Bvr::CallOverview.find(customer_id, options) }
56
-
57
- it 'merges the CallOverview command and the customer_id with options' do
58
- expected_options = options.merge({command: Bvr::CallOverview::API_COMMAND, customer: customer_id})
59
- proc {subject}.must_raise ArgumentError
60
- end
61
- end
62
-
63
-
64
- describe 'when there is a response' do
65
- let(:response) do
66
- File.read(File.join(File.dirname(__FILE__), '/..', '/..', '/fixtures/CallOverview.xml'))
67
- end
68
-
69
- subject{ Bvr::CallOverview.find(customer_id) }
70
-
71
- it 'parse the response to objects' do
72
- stub_result(response) do |connection|
73
- subject.must_be_instance_of Bvr::CallOverview
74
- subject.calls.size.must_equal 5
75
- subject.count.must_equal 10
76
-
77
- subject.calls[0].tap do |call|
78
- start_time = Time.parse("2013-12-24 18:05:26 (UTC)")
79
- call.id.must_equal "1234567890"
80
- call.calltype.must_equal "PSTNOutSip"
81
- call.start_time.must_equal start_time
82
- call.dest.must_be_instance_of Bvr::Phone
83
- call.dest.number.must_equal "+32123456788"
84
- call.duration.must_equal "00:02:21"
85
- call.relative_duration.must_equal Time.parse("00:02:21", start_time)
86
- call.charge.must_equal "0.0705"
87
- end
88
- end
89
- end
90
- end
91
- end
92
- end
93
-
94
-