File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,17 @@ module Telapi
33 class Carrier < Resource
44 class << self
55
6+ # Returns a resource collection containing Telapi::Carrier objects
7+ # See http://docs.telapi.com/v2/docs/carrier-lookup-list
8+ #
9+ # Optional params is a hash containing:
10+ # +Page+:: integer greater than 0
11+ # +PageSize+:: integer greater than 0
12+ def list ( optional_params = { } )
13+ response = Network . get ( [ 'Lookups' , 'Carrier' ] , optional_params )
14+ ResourceCollection . new ( response , 'carrier_lookups' , self )
15+ end
16+
617 # Returns a Telapi::Carrier object given a phone number
718 # See http://www.telapi.com/docs/api/rest/carrier-services/carrier-lookup/
819 def lookup ( phone_number )
@@ -13,4 +24,4 @@ def lookup(phone_number)
1324
1425 end
1526 end
16- end
27+ end
Original file line number Diff line number Diff line change 88
99 it { should be_kind_of ( Telapi ::Resource ) }
1010
11+ describe ".list" do
12+ before { stub_telapi_request ( '{ "carrier_lookups": [] }' ) }
13+
14+ it "calls api via http get and returns a ResourceCollection" do
15+ api_should_use ( :get )
16+ klass . list . should be_a ( Telapi ::ResourceCollection )
17+ end
18+
19+ context "when Carrier lookups exist" do
20+ before { stub_telapi_request ( '{ "carrier_lookups": [{ "phone_number": "+17325551234" }] }' ) }
21+
22+ it "has a collection of Carrier Lookup objects" do
23+ klass . list . first . should be_a ( klass )
24+ end
25+ end
26+ end
27+
1128 describe ".lookup" do
1229 it "calls api via http get and returns a Carrier resource" do
1330 api_should_use ( :get )
1431 klass . lookup ( '17325551234' ) . should be_a ( klass )
1532 end
1633 end
17- end
34+ end
You can’t perform that action at this time.
0 commit comments