flexmls_api 0.3.2 → 0.3.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
@@ -11,9 +11,9 @@ module FlexmlsApi
11
11
  # Main authentication step. Run before any api request unless the user session exists and is
12
12
  # still valid.
13
13
  #
14
- # :returns:
14
+ # *returns*
15
15
  # The user session object when authentication succeeds
16
- # :raises:
16
+ # *raises*
17
17
  # FlexmlsApi::ClientError when authentication fails
18
18
  def authenticate
19
19
  sig = sign("#{@api_secret}ApiKey#{@api_key}")
@@ -28,6 +28,18 @@ module FlexmlsApi
28
28
  @session
29
29
  end
30
30
 
31
+ # Delete the current session
32
+ def logout
33
+ FlexmlsApi.logger.info("Logging out.")
34
+ delete("/session/#{@session.auth_token}") unless @session.nil?
35
+ @session = nil
36
+ end
37
+
38
+ # Active session object
39
+ def session
40
+ @session
41
+ end
42
+
31
43
  # Builds an ordered list of key value pairs and concatenates it all as one big string. Used
32
44
  # specifically for signing a request.
33
45
  def build_param_string(param_hash)
@@ -6,7 +6,6 @@ module FlexmlsApi
6
6
  begin
7
7
  def self.register_on_complete(env)
8
8
  env[:response].on_complete do |finished_env|
9
- FlexmlsApi.logger.debug("hashed response: #{finished_env[:body].inspect}")
10
9
  validate_and_build_response(finished_env)
11
10
  end
12
11
  end
@@ -0,0 +1,5 @@
1
+ {
2
+ "D": {
3
+ "Success": true
4
+ }
5
+ }
@@ -0,0 +1,30 @@
1
+ require './spec/spec_helper'
2
+
3
+ describe FlexmlsApi::Authentication do
4
+ it "should give me a session object" do
5
+ stub_auth_request
6
+ stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}/session/c401736bf3d3f754f07c04e460e09573").
7
+ with(:query => {
8
+ :ApiSig => "5596eff4550d74ec6802ac2d637ae5ae",
9
+ :AuthToken => "c401736bf3d3f754f07c04e460e09573"
10
+ }).
11
+ to_return(:body => fixture("session.json"))
12
+ client = FlexmlsApi.client
13
+ stub_auth_request
14
+ session = client.get "/session/c401736bf3d3f754f07c04e460e09573"
15
+ session[0]["AuthToken"].should eq "c401736bf3d3f754f07c04e460e09573"
16
+ end
17
+ it "should delete a session" do
18
+ stub_auth_request
19
+ stub_request(:delete, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}/session/c401736bf3d3f754f07c04e460e09573").
20
+ with(:query => {
21
+ :ApiSig => "5596eff4550d74ec6802ac2d637ae5ae",
22
+ :AuthToken => "c401736bf3d3f754f07c04e460e09573"
23
+ }).
24
+ to_return(:body => fixture("success.json"))
25
+ client = FlexmlsApi.client
26
+ client.logout
27
+ client.session.should eq nil
28
+ end
29
+
30
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexmls_api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brandon Hornseth
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-28 00:00:00 -06:00
18
+ date: 2011-03-01 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -242,8 +242,10 @@ files:
242
242
  - spec/fixtures/listing_with_videos.json
243
243
  - spec/fixtures/listing_with_vtour.json
244
244
  - spec/fixtures/session.json
245
+ - spec/fixtures/success.json
245
246
  - spec/json_helper.rb
246
247
  - spec/spec_helper.rb
248
+ - spec/unit/flexmls_api/authentication_spec.rb
247
249
  - spec/unit/flexmls_api/configuration_spec.rb
248
250
  - spec/unit/flexmls_api/faraday_spec.rb
249
251
  - spec/unit/flexmls_api/models/base_spec.rb
@@ -297,6 +299,7 @@ summary: A library for interacting with the flexmls web services.
297
299
  test_files:
298
300
  - spec/json_helper.rb
299
301
  - spec/spec_helper.rb
302
+ - spec/unit/flexmls_api/authentication_spec.rb
300
303
  - spec/unit/flexmls_api/configuration_spec.rb
301
304
  - spec/unit/flexmls_api/faraday_spec.rb
302
305
  - spec/unit/flexmls_api/models/base_spec.rb