your_membership 1.0.0 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e167609f71a1eb9be5e05117ef8baa58039ba2c9
4
- data.tar.gz: 46cb16feb9c4cf28145a18b4ef23a2ebc8f79f4e
3
+ metadata.gz: c93432ed686e1f80df9f1d4fa5d33eb38785b02b
4
+ data.tar.gz: dffe41b0e69376c7669a30b184a76c405e3b2751
5
5
  SHA512:
6
- metadata.gz: a9d00bfa496efd4a21c47bbc0a613f5fab98f245a3d87d3ca252837ebd9cdafc8fa5a4af2ca6a7c0a62e231d870833f55337ce00959fd8db22894523335063fb
7
- data.tar.gz: c73d3f40ea5053b5dbebc54309be0bca063befcc2c6fa371007c393b8ff5840c166ad00969d40b6564fd5888c141a4deaac4265c0f9e1b2f9e37f4ae22ffd32d
6
+ metadata.gz: d7dae1c53e40a3d2c24d7dc8715a07c7fa41c917b316ed4b33afe3cb13239ea647e977b3bbead6bc42d1c48850d60fb6afec4620f14c552148db055c44fb2eb7
7
+ data.tar.gz: 1668ab62de7584be9e23d67016560b36c8bda85e9fcd36a9b40f40f421d5e26bf529991eb8cae686418ed55057a6645ffe49a4b75607b13ffeab9cb8d8b31a60
data/README.md CHANGED
@@ -3,6 +3,10 @@ YourMembership: Ruby SDK for the YourMembership.Com XML API
3
3
 
4
4
  _This SDK for Version 2.00 of the YourMembership.com API_
5
5
 
6
+ [![Gem Version](https://badge.fury.io/rb/your_membership.svg)](http://badge.fury.io/rb/your_membership)
7
+ [![Inline docs](http://inch-ci.org/github/ECHOInternational/your_membership.svg?branch=master)](http://rubydoc.info/gems/your_membership/1.0.0/frames)
8
+ [![Code Climate](https://codeclimate.com/github/ECHOInternational/your_membership/badges/gpa.svg)](https://codeclimate.com/github/ECHOInternational/your_membership)
9
+
6
10
  ## Installation
7
11
 
8
12
  Add this line to your application's Gemfile:
@@ -80,7 +84,7 @@ The options hash is present any time optional arguments can be passed to a metho
80
84
  `YourMembership::Events.all_search` takes one required argument (a session object/key) and up to three optional arguments passed as a hash.
81
85
 
82
86
  ```RUBY
83
- session = YourMembership::Session.new
87
+ session = YourMembership::Session.create
84
88
  options = {:SearchText => "A string to search for", :PageSize => 5, :StartRecord => 6}
85
89
  YourMembership::Events.all_search session, options
86
90
  ```
@@ -131,10 +135,10 @@ Sessions can be **generic** (unauthenticated), **authenticated**, or **abandoned
131
135
  ##### Examples:
132
136
  ```RUBY
133
137
  # Generic (unauthenticated) Session
134
- session = YourMembership::Session.new
138
+ session = YourMembership::Session.create
135
139
 
136
140
  # Authenticated Session
137
- auth_session = YourMembership::Session.new 'username', 'password'
141
+ auth_session = YourMembership::Session.create 'username', 'password'
138
142
 
139
143
  # Sessions can also be authenticated after creation in one of two ways:
140
144
 
@@ -164,7 +168,7 @@ member = YourMembership::Member.create_by_authentication 'username', 'password'
164
168
  # Members can also be created by passing in an already existing Session instance
165
169
  # this is especially useful when Sessions are authenticated through token
166
170
  # authentication.
167
- auth_session = YourMembership::Session.new 'username', 'password'
171
+ auth_session = YourMembership::Session.create 'username', 'password'
168
172
  member = YourMembership::Member.create_from_session auth_session
169
173
  ```
170
174
  _Member objects can be created directly without a bound Session, but there is (as of yet) very little use for this._
@@ -59,7 +59,7 @@ module YourMembership
59
59
  # @param [String] password The password in cleartext
60
60
  # @return [YourMembership::Member] Returns a new Member object with associated authenticated Session object
61
61
  def self.create_by_authentication(username, password)
62
- session = YourMembership::Session.new username, password
62
+ session = YourMembership::Session.create username, password
63
63
  create_from_session(session)
64
64
  end
65
65
 
@@ -169,7 +169,7 @@ module YourMembership
169
169
  response = post('/', :body => build_XML_request('Sa.Members.Profile.Create', nil, options))
170
170
  response_valid? response
171
171
  YourMembership::Sa::Auth.authenticate(
172
- YourMembership::Session.new,
172
+ YourMembership::Session.create,
173
173
  profile.data['Username'],
174
174
  profile.data['Password']
175
175
  )
@@ -14,30 +14,35 @@ module YourMembership
14
14
  # * *Abandoned sessions* are no longer usable and are essentially the same as logging out.
15
15
  #
16
16
  # @example Generic (unauthenticated) Session
17
- # session = YourMembership::Session.new # => <YourMembership::Session>
17
+ # session = YourMembership::Session.create # => <YourMembership::Session>
18
18
  # @example Authenticated Session
19
- # auth_session = YourMembership::Session.new 'username', 'password' # => <YourMembership::Session>
19
+ # auth_session = YourMembership::Session.create 'username', 'password' # => <YourMembership::Session>
20
20
  #
21
21
  # @attr_reader [String] session_id The unique session identifier provided by the API
22
22
  # @attr_reader [String, Nil] user_id The user id of the user bound to the session, if one exists.
23
23
  class Session < YourMembership::Base
24
- attr_reader :session_id, :user_id
24
+ attr_reader :session_id, :user_id, :call_id
25
+
26
+ # Generates an empty session
27
+ def initialize(session_id = nil, call_id = 1, user_id = nil)
28
+ @session_id = session_id
29
+ @call_id = call_id
30
+ @user_id = user_id
31
+ end
25
32
 
26
33
  # @see https://api.yourmembership.com/reference/2_00/Session_Create.htm
27
34
  # @param user_name [String] Constructor takes optional parameters of user_name and password. If supplied then the
28
35
  # session will be automatically authenticated upon instantiation.
29
36
  # @param password [String]
30
- def initialize(user_name = nil, password = nil)
31
- @call_id = 1
32
- @user_id = nil
33
-
34
- response = self.class.post('/', :body => self.class.build_XML_request('Session.Create'))
37
+ def self.create(user_name = nil, password = nil)
38
+ response = post('/', :body => build_XML_request('Session.Create'))
35
39
 
36
- if self.class.response_valid? response
37
- @session_id = response['YourMembership_Response']['Session.Create']['SessionID']
40
+ if response_valid? response
41
+ session = new response['YourMembership_Response']['Session.Create']['SessionID']
38
42
  end
39
43
 
40
- authenticate user_name, password if user_name
44
+ session.authenticate user_name, password if user_name
45
+ session
41
46
  end
42
47
 
43
48
  # @return [Integer] Auto Increments ad returns the call_id for the session as required by the YourMembership.com API
@@ -1,3 +1,3 @@
1
1
  module YourMembership
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: your_membership
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Flood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-13 00:00:00.000000000 Z
11
+ date: 2014-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty