your_membership 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,197 @@
1
+ require "spec_helper"
2
+ require "profile"
3
+
4
+ describe YourMembership::Profile do
5
+ before do
6
+ @sample_profile = {
7
+ "ID"=>"F8C2BEFD-GF37-5CBC-B750-487162B95CDF",
8
+ "WebsiteID"=>"16273406",
9
+ "PrimaryGroupCode"=>nil,
10
+ "IsMember"=>"1",
11
+ "IsNonMember"=>"0",
12
+ "Registered"=>"2014-06-12 14:53:30",
13
+ "LastUpdated"=>"2014-08-07 14:31:34",
14
+ "ImportID"=>"YM-40539-798958-4242",
15
+ "ConstituentID"=>nil,
16
+ "EmailAddr"=>"nflood@echonet.org",
17
+ "EmailBounced"=>"0",
18
+ "NamePrefix"=>"Mr",
19
+ "FirstName"=>"Nate",
20
+ "MiddleName"=>nil,
21
+ "LastName"=>"Flood",
22
+ "NameSuffix"=>nil,
23
+ "Nickname"=>"Nate Flood",
24
+ "Gender"=>"M",
25
+ "Birthdate"=>nil,
26
+ "MaritalStatus"=>nil,
27
+ "MaidenName"=>nil,
28
+ "SpouseName"=>nil,
29
+ "AnniversaryDate"=>nil,
30
+ "Employer"=>"ECHO INC.",
31
+ "Title"=>"Digital Media Specialist",
32
+ "Profession"=>nil,
33
+ "Membership"=>"ECHO Interns and Current Staff",
34
+ "MembershipExpiry"=>nil,
35
+ "MemberTypeCode"=>"ECHOstaff",
36
+ "Approved"=>"1",
37
+ "Suspended"=>"0",
38
+ "Username"=>"nflood",
39
+ "PasswordHash"=>"1E10A122BDB35AN022FEJF617BE14527E72KA26E",
40
+ "AltEmailAddr"=>nil,
41
+ "HomeAddrLines"=>nil,
42
+ "HomeCity"=>nil,
43
+ "HomeLocation"=>nil,
44
+ "HomePostalCode"=>nil,
45
+ "HomeCountry"=>nil,
46
+ "Website"=>nil,
47
+ "HomePhAreaCode"=>nil,
48
+ "HomePhone"=>nil,
49
+ "MobileAreaCode"=>nil,
50
+ "Mobile"=>nil,
51
+ "EmpAddrLines"=>"17391 Durrance Road",
52
+ "EmpCity"=>"North Fort Myers",
53
+ "EmpLocation"=>"Florida",
54
+ "EmpPostalCode"=>"33917",
55
+ "EmpCountry"=>"United States",
56
+ "BusinessWebsite"=>nil,
57
+ "EmpPhAreaCode"=>"239",
58
+ "EmpPhone"=>"567-3355",
59
+ "EmpFaxAreaCode"=>nil,
60
+ "EmpFax"=>nil,
61
+ "LastRenewalReminderSent"=>nil,
62
+ "GamificationPoints"=>"198",
63
+ "HeadshotImageURI"=>"http://c.yourmembership.com/sites/echocommunity.site-ym.com/photos/alumni/20140725_144857_16292.jpg",
64
+ "MasterID"=>nil,
65
+ "LastRenewalDate"=>"2014-06-12 14:53:00",
66
+ "ApprovalDate"=>"6/12/2014 2:54:19 PM",
67
+ "LastModifiedDate"=>"2014-08-07 14:31:34",
68
+ "QueuedForDelete"=>"0",
69
+ "QueuedForDeleteDate"=>nil,
70
+ "Latitude"=>"0",
71
+ "Longitude"=>"0",
72
+ "CustomFieldResponses"=>{
73
+ "CustomFieldResponse"=>[
74
+ {"Values"=>{"Value"=>"USA"}, "FieldCode"=>"Workingcountry", "Visibility"=>""},
75
+ {"Values"=>{"Value"=>"other"}, "FieldCode"=>"UserType", "Visibility"=>""},
76
+ {"Values"=>{"Value"=>"North America"}, "FieldCode"=>"region", "Visibility"=>""},
77
+ {"Values"=>{"Value"=>["North","South"]}, "FieldCode"=>"PCVenddate", "Visibility"=>""} ]
78
+ }
79
+ }
80
+ end
81
+ it "accepts and sets required parameters for new profiles" do
82
+ profile = YourMembership::Profile.create_new('afirstname', 'alastname', 'amembertypecode', 'ausername', 'apassword')
83
+ profile.data['FirstName'].should == 'afirstname'
84
+ profile.data['LastName'].should == 'alastname'
85
+ profile.data['MemberTypeCode'].should == 'amembertypecode'
86
+ profile.data['Username'].should == 'ausername'
87
+ profile.data['Password'].should == 'apassword'
88
+ end
89
+
90
+ it "adds arbitrary keys when creating new profiles" do
91
+ profile_hash = {'foo' => 'bar'}
92
+ profile = YourMembership::Profile.create_new('afirstname', 'alastname', 'amembertypecode', 'ausername', nil, profile_hash)
93
+ profile.data.should include 'foo'
94
+ profile.data['foo'].should == 'bar'
95
+ end
96
+
97
+ it "adds arbitrary custom keys when creating new profiles" do
98
+ profile_custom_hash = {'foo' => 'bar'}
99
+ profile = YourMembership::Profile.create_new('afirstname', 'alastname', 'amembertypecode', 'ausername', nil, {}, profile_custom_hash)
100
+ profile.custom_data.should include 'foo'
101
+ profile.custom_data['foo'].should == 'bar'
102
+ end
103
+
104
+ it "creates an object based on a profile hash" do
105
+ profile = YourMembership::Profile.new(@sample_profile)
106
+ profile.data.should include 'FirstName'
107
+ end
108
+
109
+ it "adds arbitrary keys when creating based on a profile hash" do
110
+ profile_hash = {'foo' => 'bar'}
111
+ profile = YourMembership::Profile.new(profile_hash)
112
+ profile.data.should include 'foo'
113
+ profile.data['foo'].should == 'bar'
114
+ end
115
+
116
+ it "returns the output hash when asked" do
117
+ profile_hash = {'foo' => 'bar'}
118
+ profile = YourMembership::Profile.new(profile_hash)
119
+ profile.to_h.should be_a(Hash)
120
+ profile.to_h.should include 'foo'
121
+ end
122
+
123
+ it "does not return nil values in the output hash" do
124
+ profile_hash = {'foo' => 'bar', 'far' => nil}
125
+ profile = YourMembership::Profile.new(profile_hash)
126
+ profile.to_h.should include 'foo'
127
+ profile.to_h.should_not include 'far'
128
+ end
129
+
130
+ it "can be manipulated directly through the data attribute" do
131
+ profile_hash = {'foo' => 'bar'}
132
+ profile = YourMembership::Profile.new(profile_hash)
133
+ expect {profile.data['foo'] = 'baz'}.to change{profile.data['foo']}.from('bar').to('baz')
134
+ end
135
+
136
+ it "has a custom_data attribute" do
137
+ profile = YourMembership::Profile.new
138
+ expect profile.should respond_to 'custom_data'
139
+ end
140
+
141
+ it "can be manipulated directly through the custom data attribute" do
142
+ profile = YourMembership::Profile.new
143
+ profile.custom_data['foo'] = 'bar'
144
+ expect profile.custom_data.should include 'foo'
145
+ expect profile.custom_data['foo'].should == 'bar'
146
+ expect {profile.custom_data['foo'] = 'baz'}.to change{profile.custom_data['foo']}.from('bar').to('baz')
147
+ end
148
+
149
+ it "adds a 'CustomFieldResponses' key as a hash" do
150
+ profile_hash = {'foo' => 'bar'}
151
+ profile = YourMembership::Profile.new(profile_hash)
152
+ expect profile.to_h.should include 'CustomFieldResponses'
153
+ expect profile.to_h['CustomFieldResponses'].should be_a(Hash)
154
+ end
155
+
156
+ it "contains custom_data in the 'CustomFieldResponses' key hash" do
157
+ profile = YourMembership::Profile.new
158
+ profile.custom_data['foo'] = 'bar'
159
+ expect profile.to_h['CustomFieldResponses'].should include 'foo'
160
+ expect profile.to_h['CustomFieldResponses']['foo'].should == 'bar'
161
+ end
162
+
163
+ it "accepts strings as custom data" do
164
+ profile = YourMembership::Profile.new
165
+ profile.custom_data['foo'] = 'bar'
166
+ expect profile.to_h['CustomFieldResponses']['foo'].should be_a(String)
167
+ end
168
+
169
+ it "accepts arrays as custom data" do
170
+ profile = YourMembership::Profile.new
171
+ profile.custom_data['foo'] = ['bar', 'bat', 'baz']
172
+ expect profile.to_h['CustomFieldResponses']['foo'].should be_a(Array)
173
+ expect profile.to_h['CustomFieldResponses']['foo'].should include 'baz'
174
+ end
175
+
176
+ it "does not contain nil keys in the 'CustomFieldResponses'" do
177
+ profile = YourMembership::Profile.new
178
+ profile.custom_data['foo'] = nil
179
+ expect profile.to_h['CustomFieldResponses'].should_not include 'foo'
180
+ end
181
+
182
+ it "does not include 'CustomFieldResponses' in the data hash when creating from a profile hash" do
183
+ profile = YourMembership::Profile.new(@sample_profile)
184
+ profile.data.should_not include 'CustomFieldResponses'
185
+ end
186
+
187
+ it "puts 'CustomFieldResponses' into the custom_data hash when creating from a profile hash" do
188
+ profile = YourMembership::Profile.new(@sample_profile)
189
+ profile.custom_data.should include 'Workingcountry'
190
+ end
191
+
192
+ it "converts 'CustomFieldResponse' values to strings or arrays" do
193
+ profile = YourMembership::Profile.new(@sample_profile)
194
+ profile.custom_data.should include 'Workingcountry'
195
+ profile.custom_data['Workingcountry'].should == "USA"
196
+ end
197
+ end
@@ -0,0 +1,78 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, make a
10
+ # separate helper file that requires this one and then use it only in the specs
11
+ # that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # The settings below are suggested to provide a good initial experience
19
+ # with RSpec, but feel free to customize to your heart's content.
20
+ #begin
21
+ # These two settings work together to allow you to limit a spec run
22
+ # to individual examples or groups you care about by tagging them with
23
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
24
+ # get run.
25
+ config.filter_run :focus
26
+ config.run_all_when_everything_filtered = true
27
+
28
+ # Many RSpec users commonly either run the entire suite or an individual
29
+ # file, and it's useful to allow more verbose output when running an
30
+ # individual spec file.
31
+ if config.files_to_run.one?
32
+ # Use the documentation formatter for detailed output,
33
+ # unless a formatter has already been configured
34
+ # (e.g. via a command-line flag).
35
+ config.default_formatter = 'doc'
36
+ end
37
+
38
+ # Print the 10 slowest examples and example groups at the
39
+ # end of the spec run, to help surface which specs are running
40
+ # particularly slow.
41
+ config.profile_examples = 10
42
+
43
+ # Run specs in random order to surface order dependencies. If you find an
44
+ # order dependency and want to debug it, you can fix the order by providing
45
+ # the seed, which is printed after each run.
46
+ # --seed 1234
47
+ config.order = :random
48
+
49
+ # Seed global randomization in this process using the `--seed` CLI option.
50
+ # Setting this allows you to use `--seed` to deterministically reproduce
51
+ # test failures related to randomization by passing the same `--seed` value
52
+ # as the one that triggered the failure.
53
+ Kernel.srand config.seed
54
+
55
+ # rspec-expectations config goes here. You can use an alternate
56
+ # assertion/expectation library such as wrong or the stdlib/minitest
57
+ # assertions if you prefer.
58
+ config.expect_with :rspec do |expectations|
59
+ # Enable only the newer, non-monkey-patching expect syntax.
60
+ # For more details, see:
61
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
62
+ expectations.syntax = [:expect, :should]
63
+ end
64
+
65
+ # rspec-mocks config goes here. You can use an alternate test double
66
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
67
+ config.mock_with :rspec do |mocks|
68
+ # Enable only the newer, non-monkey-patching expect syntax.
69
+ # For more details, see:
70
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
71
+ mocks.syntax = :expect
72
+
73
+ # Prevents you from mocking or stubbing a method that does not exist on
74
+ # a real object. This is generally recommended.
75
+ mocks.verify_partial_doubles = true
76
+ end
77
+ #end
78
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'your_membership/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "your_membership"
8
+ spec.version = YourMembership::VERSION
9
+ spec.authors = ["Nate Flood"]
10
+ spec.email = ["nflood@echonet.org"]
11
+ spec.summary = %q{Ruby SDK for interfacing with the YourMembership.com XML API}
12
+ spec.description = %q{The YourMembership member community product offers a wide range of features through its
13
+ external API. This API is implemented through a specialized set of XML POSTS which is not easily abstracted into a
14
+ RESTful interface. The purpose of this SDK is to enable Ruby developers and systems using Ruby on Rails to interface
15
+ natively with the YourMembership.com API.}
16
+ spec.homepage = ""
17
+ spec.license = "MIT"
18
+
19
+ spec.files = `git ls-files -z`.split("\x0")
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "httparty", "~>0.13.1"
25
+ spec.add_dependency "nokogiri", "~>1.6"
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.6"
28
+ spec.add_development_dependency "rake"
29
+ spec.add_development_dependency "rspec"
30
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: your_membership
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Nate Flood
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.13.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.13.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: |-
84
+ The YourMembership member community product offers a wide range of features through its
85
+ external API. This API is implemented through a specialized set of XML POSTS which is not easily abstracted into a
86
+ RESTful interface. The purpose of this SDK is to enable Ruby developers and systems using Ruby on Rails to interface
87
+ natively with the YourMembership.com API.
88
+ email:
89
+ - nflood@echonet.org
90
+ executables: []
91
+ extensions: []
92
+ extra_rdoc_files: []
93
+ files:
94
+ - .gitignore
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - lib/httparty/patch.rb
100
+ - lib/your_membership.rb
101
+ - lib/your_membership/base.rb
102
+ - lib/your_membership/commerce.rb
103
+ - lib/your_membership/config.rb
104
+ - lib/your_membership/convert.rb
105
+ - lib/your_membership/error.rb
106
+ - lib/your_membership/events.rb
107
+ - lib/your_membership/feeds.rb
108
+ - lib/your_membership/member.rb
109
+ - lib/your_membership/members.rb
110
+ - lib/your_membership/people.rb
111
+ - lib/your_membership/profile.rb
112
+ - lib/your_membership/sa.rb
113
+ - lib/your_membership/sa_auth.rb
114
+ - lib/your_membership/sa_certifications.rb
115
+ - lib/your_membership/sa_commerce.rb
116
+ - lib/your_membership/sa_events.rb
117
+ - lib/your_membership/sa_export.rb
118
+ - lib/your_membership/sa_groups.rb
119
+ - lib/your_membership/sa_member.rb
120
+ - lib/your_membership/sa_members.rb
121
+ - lib/your_membership/sa_nonmembers.rb
122
+ - lib/your_membership/sa_people.rb
123
+ - lib/your_membership/session.rb
124
+ - lib/your_membership/version.rb
125
+ - spec/lib/profile_spec.rb
126
+ - spec/spec_helper.rb
127
+ - your_membership.gemspec
128
+ homepage: ''
129
+ licenses:
130
+ - MIT
131
+ metadata: {}
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ requirements: []
147
+ rubyforge_project:
148
+ rubygems_version: 2.3.0
149
+ signing_key:
150
+ specification_version: 4
151
+ summary: Ruby SDK for interfacing with the YourMembership.com XML API
152
+ test_files:
153
+ - spec/lib/profile_spec.rb
154
+ - spec/spec_helper.rb
155
+ has_rdoc: