spark_api 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,7 +6,7 @@ A Ruby wrapper for the Spark REST API. Loosely based on ActiveResource to provid
6
6
  Documentation
7
7
  -------------
8
8
 
9
- For further client documentation, please consult our [wiki](wiki).
9
+ For further client documentation, please consult our [wiki](/sparkapi/spark_api/wiki).
10
10
 
11
11
  For full information on the API, see [http://sparkplatform.com/docs/overview/api](http://sparkplatform.com/docs/overview/api)
12
12
 
@@ -55,7 +55,7 @@ The base client provides a bare bones HTTP interface for working with the RESTfu
55
55
  SparkApi.client.put "/listings/#{listing_id}/photos/#{photo_id}", updated_photo_name_hash
56
56
  SparkApi.client.delete "/listings/#{listing_id}/photos/#{photo_id}"
57
57
 
58
- #### [API Models](wiki/API-Models)
58
+ #### [API Models](/sparkapi/spark_api/wiki/API-Models)
59
59
  The client also provides ActiveModelesque interface for working with the api responses. Notably, the models use finder methods for searching, and similar instanciation and persistence also on supported services.
60
60
 
61
61
  # Tip: mixin the models so you can use them without namespaces
@@ -71,20 +71,20 @@ Authentication Types
71
71
  --------------
72
72
  Authentication is handled transparently by the request framework in the gem, so you should never need to manually make an authentication request. More than one mode of authentication is supported, so the client needs to be configured accordingly.
73
73
 
74
- #### [Spark API Authentication](wiki/Spark-Authentication) (Default)
74
+ #### [Spark API Authentication](/sparkapi/spark_api/wiki/Spark-Authentication) (Default)
75
75
  Usually supplied for a single user, this authentication mode is the simplest, and is setup as the default. The example usage above demonstrates how to get started using this authentication mode.
76
76
 
77
- #### [OpenId/OAuth2 Combined Flow](wiki/Hybrid-Authentication) (Preferred)
77
+ #### [OpenId/OAuth2 Combined Flow](/sparkapi/spark_api/wiki/Hybrid-Authentication) (Preferred)
78
78
  Authorization mode the separates application and user authentication. This mode requires the end user to be redirected to Spark Platform's openid endpoint. See "script/combined_flow_example.rb" for an example.
79
79
 
80
80
  Read more about Spark Platform's combined flow <a href="http://sparkplatform.com/docs/authentication/openid_oauth2_authentication">here</a>.
81
81
 
82
- #### [OAuth2 Authorization](wiki/OAuth2-Only-Authentication)
82
+ #### [OAuth2 Authorization](/sparkapi/spark_api/wiki/OAuth2-Only-Authentication)
83
83
  Authorization mode the separates application and user authentication. This mode requires the end user to be redirected to Spark Platform's auth endpoint. See "script/oauth2_example.rb" for an example.
84
84
 
85
85
  Read more about Spark Platform's OAuth 2 flow <a href="http://sparkplatform.com/docs/authentication/oauth2_authentication">here</a>.
86
86
 
87
- #### [OpenId Authentication](wiki/OpenId-Only-Authentication)
87
+ #### [OpenId Authentication](/sparkapi/spark_api/wiki/OpenId-Only-Authentication)
88
88
  There is also the option to only access a user's Spark Platform identity without accessing any data (e.g. listings, contacts, etc.). In circumstances where you ONLY with to authenticate users through the Spark Platform, but do not have a use case to access any of their data, consider the OpenId authentication flow in lieu of API Authentication or the Combined flow.
89
89
 
90
90
  Read more about Spark Platform's OpenId flow <a href="http://sparkplatform.com/docs/authentication/openid_authentication">here</a>.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.2.1
@@ -40,12 +40,12 @@ module SparkApi
40
40
  end
41
41
 
42
42
  def attribute_change(attr)
43
- [changed_attributes[attr], __send__(attr)] if attribute_changed?(attr)
43
+ [changed_attributes[attr], @attributes[attr.to_s]] if attribute_changed?(attr)
44
44
  end
45
45
 
46
46
  def attribute_will_change!(attr)
47
47
  begin
48
- value = __send__(attr)
48
+ value = @attributes[attr.to_s]
49
49
  value = value.duplicable? ? value.clone : value
50
50
  rescue TypeError, NoMethodError; end
51
51
 
@@ -11,10 +11,14 @@ module SparkApi
11
11
  when :all then find_every(options)
12
12
  when :first then find_every(options).first
13
13
  when :last then find_every(options).last
14
- when :one then find_one(options)
14
+ when :one then find_every(options.merge(:_limit => 1)).first
15
15
  else find_single(scope, options)
16
16
  end
17
17
  end
18
+
19
+ def find_one(*arguments)
20
+ find(:one, *arguments)
21
+ end
18
22
 
19
23
  def first(*arguments)
20
24
  find(:first, *arguments)
@@ -30,10 +34,6 @@ module SparkApi
30
34
  collect(connection.get("/#{element_name}", options))
31
35
  end
32
36
 
33
- def find_one(options)
34
- raise NotImplementedError # TODO um... what?
35
- end
36
-
37
37
  def find_single(scope, options)
38
38
  resp = connection.get("/#{element_name}/#{scope}", options)
39
39
  new(resp.first)
@@ -86,6 +86,10 @@ module SparkApi
86
86
  nearby_args = {:_lat => latitude, :_lon => longitude}.merge(arguments)
87
87
  collect(connection.get("/listings/nearby", nearby_args))
88
88
  end
89
+
90
+ def self.tour_of_homes(arguments={})
91
+ collect(connection.get("/listings/tourofhomes", arguments))
92
+ end
89
93
 
90
94
  def tour_of_homes(arguments={})
91
95
  @tour_of_homes ||= TourOfHome.find_by_listing_key(self.Id, arguments)
@@ -0,0 +1,95 @@
1
+ {
2
+ "D": {
3
+ "Results": [
4
+ {
5
+ "ResourceUri": "/v1/listings/20060725224713296297000000",
6
+ "StandardFields": {
7
+ "StreetNumber": "7298",
8
+ "Longitude": "-116.3237",
9
+ "City": "Bonners Ferry",
10
+ "ListingId": "06-9395",
11
+ "PublicRemarks": "Afforadable home in town close to hospital,yet quiet country like setting. Good views. Must see",
12
+ "BuildingAreaTotal": "924.0",
13
+ "YearBuilt": 1977,
14
+ "StreetName": "BIRCH",
15
+ "ListPrice": "50000.0",
16
+ "PostalCode": "83805",
17
+ "Latitude": "48.7001",
18
+ "BathsThreeQuarter": null,
19
+ "BathsFull": null,
20
+ "BathsTotal": "1.0",
21
+ "StateOrProvince": "ID",
22
+ "PropertyType": "A",
23
+ "StreetAdditionalInfo": null,
24
+ "StreetDirPrefix": null,
25
+ "BedsTotal": 3,
26
+ "StreetDirSuffix": null,
27
+ "ListingKey": "20060725224713296297000000",
28
+ "ListOfficeName": "Century 21 On The Lake",
29
+ "BathsHalf": null,
30
+ "ModificationTimestamp": "2010-11-22T20:47:21Z",
31
+ "CountyOrParish": "Boundary"
32
+ },
33
+ "TourOfHomes": [{
34
+ "AdditionalInfo": [
35
+ {"Hosted By": "Mr. Agent"},
36
+ {"Hosted Phone": "111-222-3333"},
37
+ {"Area": "North Fargo"}
38
+ ],
39
+ "Comments": "First listing tour",
40
+ "Date": "05/14/2012",
41
+ "Id": "20120509194700383011000000",
42
+ "ResourceUri": "/vX/listings/20000612234839640464000000/tourofhomes/20120509194700383011000000",
43
+ "StartTime": "12:00 PM",
44
+ "EndTime": "5:00 PM"
45
+ }],
46
+ "Id": "20060725224713296297000000"
47
+ },
48
+ {
49
+ "ResourceUri": "/v1/listings/20060725224713296972000000",
50
+ "StandardFields": {
51
+ "StreetNumber": "7294",
52
+ "Longitude": "-116.3237",
53
+ "City": "Bonners Ferry",
54
+ "ListingId": "06-9396",
55
+ "PublicRemarks": "Afforadable home in town close to hospital,yet quiet country like setting. Good views. Must see",
56
+ "BuildingAreaTotal": "924.0",
57
+ "YearBuilt": 1977,
58
+ "StreetName": "BIRCH",
59
+ "ListPrice": "50000.0",
60
+ "PostalCode": "83805",
61
+ "Latitude": "48.7041",
62
+ "BathsThreeQuarter": null,
63
+ "BathsFull": null,
64
+ "BathsTotal": "1.0",
65
+ "StateOrProvince": "ID",
66
+ "PropertyType": "A",
67
+ "StreetAdditionalInfo": null,
68
+ "StreetDirPrefix": null,
69
+ "BedsTotal": 3,
70
+ "StreetDirSuffix": null,
71
+ "ListingKey": "20060725224713296972000000",
72
+ "ListOfficeName": "Century 21 On The Lake",
73
+ "BathsHalf": null,
74
+ "ModificationTimestamp": "2010-11-22T20:47:21Z",
75
+ "CountyOrParish": "Boundary"
76
+ },
77
+ "TourOfHomes": [{
78
+ "AdditionalInfo": [
79
+ {"Hosted By": "Mr. Agent"},
80
+ {"Hosted Phone": "111-222-3333"},
81
+ {"Area": "North Fargo"}
82
+ ],
83
+ "Comments": "First listing tour",
84
+ "Date": "05/14/2012",
85
+ "Id": "20120509194700383011000000",
86
+ "ResourceUri": "/vX/listings/20000612234839640464000000/tourofhomes/20120509194700383011000000",
87
+ "StartTime": "12:00 PM",
88
+ "EndTime": "5:00 PM"
89
+ }],
90
+ "Id": "20060725224713296972000000"
91
+ }
92
+ ],
93
+ "Success": true
94
+ }
95
+ }
@@ -9,17 +9,27 @@ describe Finders, "Finders model" do
9
9
 
10
10
  before(:each) do
11
11
  stub_auth_request
12
- stub_api_get("/my_resource", 'finders.json')
13
12
  end
14
13
 
15
14
  it "should get first result" do
15
+ stub_api_get("/my_resource", 'finders.json')
16
16
  resource = MyResource.first
17
17
  resource.Id.should eq(1)
18
18
  end
19
19
 
20
20
  it "should get last result" do
21
+ stub_api_get("/my_resource", 'finders.json')
21
22
  resource = MyResource.last
22
23
  resource.Id.should eq(2)
23
24
  end
24
25
 
26
+ it "should find one result" do
27
+ stub_api_get("/my_resource", 'finders.json', {
28
+ :_limit => 1,
29
+ :_filter => "Something Eq 'dude'"
30
+ })
31
+ resource = MyResource.find_one(:_filter => "Something Eq 'dude'")
32
+ resource.Id.should eq(1)
33
+ end
34
+
25
35
  end
@@ -51,6 +51,19 @@ describe Listing do
51
51
  'Date'=>"10/01/2010",
52
52
  'StartTime'=>"09:00:00-07:00",
53
53
  'EndTime'=>"12:00:00-07:00"
54
+ }],
55
+ "TourOfHomes" => [{
56
+ "AdditionalInfo" => [
57
+ {"Hosted By" => "Mr. Agent"},
58
+ {"Hosted Phone" => "111-222-3333"},
59
+ {"Area" => "North Fargo"}
60
+ ],
61
+ "Comments" => "First listing tour",
62
+ "Date" => "05/14/2012",
63
+ "Id" => "20120509194700383011000000",
64
+ "ResourceUri" => "/vX/listings/20000612234839640464000000/tourofhomes/20120509194700383011000000",
65
+ "StartTime" => "12:00 PM",
66
+ "EndTime" => "5:00 PM"
54
67
  }]
55
68
  },
56
69
  "Id"=>"20080619000032866372000000"
@@ -326,6 +339,19 @@ describe Listing do
326
339
  l.length.should == 1
327
340
  end
328
341
  end
342
+
343
+ context "/listings/tourofhomes", :support do
344
+ on_get_it "should return tours of homes" do
345
+ s = stub_api_get('/listings/tourofhomes', 'listings/tour_of_homes_search.json')
346
+
347
+ listings = Listing.tour_of_homes
348
+
349
+ listings.should be_an(Array)
350
+ listings.count.should eq(2)
351
+
352
+ end
353
+ end
354
+
329
355
  end
330
356
 
331
357
  after(:each) do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spark_api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 0
10
- version: 1.2.0
9
+ - 1
10
+ version: 1.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brandon Hornseth
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-11-15 00:00:00 Z
19
+ date: 2012-11-30 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  type: :runtime
@@ -439,6 +439,7 @@ files:
439
439
  - spec/fixtures/listings/put.json
440
440
  - spec/fixtures/listings/with_permissions.json
441
441
  - spec/fixtures/listings/with_vtour.json
442
+ - spec/fixtures/listings/tour_of_homes_search.json
442
443
  - spec/fixtures/listings/with_photos.json
443
444
  - spec/fixtures/listings/shared_listing_new.json
444
445
  - spec/fixtures/listings/videos_index.json
@@ -620,6 +621,7 @@ test_files:
620
621
  - spec/fixtures/listings/put.json
621
622
  - spec/fixtures/listings/with_permissions.json
622
623
  - spec/fixtures/listings/with_vtour.json
624
+ - spec/fixtures/listings/tour_of_homes_search.json
623
625
  - spec/fixtures/listings/with_photos.json
624
626
  - spec/fixtures/listings/shared_listing_new.json
625
627
  - spec/fixtures/listings/videos_index.json