your_membership 1.1.1 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +21 -0
- data/README.md +5 -0
- data/lib/httparty/ym_xml_parser.rb +29 -0
- data/lib/your_membership.rb +0 -2
- data/lib/your_membership/base.rb +11 -0
- data/lib/your_membership/sa_members.rb +2 -1
- data/lib/your_membership/version.rb +1 -1
- data/spec/lib/httparty/ym_xml_parser_spec.rb +29 -0
- data/spec/lib/your_membership/base_spec.rb +21 -0
- data/spec/lib/your_membership/profile_spec.rb +1 -0
- data/spec/spec_helper.rb +2 -2
- data/your_membership.gemspec +3 -3
- metadata +22 -13
- data/lib/httparty/patch.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0414125b59ee2d25c40031650648bc7c0b7cafe877f40df5509a49ea0b05f7d9
|
4
|
+
data.tar.gz: f72d79722d4dae7e6b1d93e2301a076ebba515ad7c2e50cc454fff04d22305a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7b76af5088d8cf1d24f09f041252efff15453112c1ef60559a53a570c67591c2bd4501fbc238570ca1ae9b2e7ee1aeff53c1fe207ea5fbde3ad0c285221b52a
|
7
|
+
data.tar.gz: 58ca1793293a33e92625f237c9480b72ce901d09863fa0dc43f82433a1a240dce653e9520f13138ea8682a23c4c9690ceb3d9d681b653bb7a935689824230915
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,27 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
|
5
5
|
## [Unreleased]
|
6
6
|
|
7
|
+
## [1.1.6] - 2021-02-17
|
8
|
+
### Added
|
9
|
+
- Allow httparty v0.18.x
|
10
|
+
|
11
|
+
## [1.1.5] - 2018-03-21
|
12
|
+
### Added
|
13
|
+
- Allow httparty v0.16.x
|
14
|
+
|
15
|
+
## [1.1.4] - 2017-08-18
|
16
|
+
### Fixed
|
17
|
+
- HTTParty monkey patch now handles nils properly.
|
18
|
+
|
19
|
+
## [1.1.3] - 2017-03-13
|
20
|
+
### Fixed
|
21
|
+
- Allow YourMembership::Sa::Members.profile_create to pass along
|
22
|
+
a hashed password when one is present.
|
23
|
+
|
24
|
+
## [1.1.2] - 2017-02-16
|
25
|
+
### Added
|
26
|
+
- Allow httparty v0.14.x
|
27
|
+
|
7
28
|
## [1.1.1] - 2016-03-23
|
8
29
|
### Fixed
|
9
30
|
- Crash in `Profile#parse_custom_field_responses` when there are no
|
data/README.md
CHANGED
@@ -252,6 +252,11 @@ Thanks to grants and donations from people like you, ECHO is able to connect tra
|
|
252
252
|
|
253
253
|
To find out more about ECHO, or to help with the work that is being done worldwide please visit http://www.echonet.org
|
254
254
|
|
255
|
+
## Contributors
|
256
|
+
npflood
|
257
|
+
sbleon
|
258
|
+
mmccarthy15
|
259
|
+
|
255
260
|
## Contributing
|
256
261
|
|
257
262
|
If you find a problem with this library or would like to contribute an improvement please fork and submit a pull request.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'httparty/parser'
|
2
|
+
|
3
|
+
module HTTParty
|
4
|
+
# Bug Fix for HTML encoded < and > in XML body. In order to parse the HTML
|
5
|
+
# encoded documents returned by the YourMembership API we need to HTML decode
|
6
|
+
# the <![CDATA[ tags.
|
7
|
+
#
|
8
|
+
# @api private
|
9
|
+
class YMXMLParser < HTTParty::Parser
|
10
|
+
# @api private
|
11
|
+
# @override
|
12
|
+
def body
|
13
|
+
decode(@body)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
# @api private
|
19
|
+
def decode(body)
|
20
|
+
# <![CDATA[ = <![CDATA[
|
21
|
+
# ]]> = ]]>
|
22
|
+
if !body.nil? && body.include?('<![CDATA[')
|
23
|
+
body.gsub! '<![CDATA[', '<![CDATA['
|
24
|
+
body.gsub! ']]>', ']]>'
|
25
|
+
end
|
26
|
+
body
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/your_membership.rb
CHANGED
data/lib/your_membership/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'httparty/ym_xml_parser'
|
2
|
+
|
1
3
|
module YourMembership
|
2
4
|
# Base Class inherited by all Your Membership SDK Classes.
|
3
5
|
class Base
|
@@ -22,6 +24,15 @@ module YourMembership
|
|
22
24
|
end
|
23
25
|
# rubocop:enable Style/ClassVars
|
24
26
|
|
27
|
+
# Fix bad XML from YM API by using custom parser.
|
28
|
+
# @api private
|
29
|
+
# @override HTTParty::ClassMethods#post
|
30
|
+
# @return [HTTParty::Response]
|
31
|
+
def self.post(path, options = {}, &block)
|
32
|
+
opt = options.merge(parser: ::HTTParty::YMXMLParser)
|
33
|
+
super(path, opt, &block)
|
34
|
+
end
|
35
|
+
|
25
36
|
# A Guard Method that returns true if the response from the API can be processed and raises an exception if not.
|
26
37
|
# @param [Hash] response
|
27
38
|
# @return [Boolean] true if no errors found.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module HTTParty
|
4
|
+
RSpec.describe YMXMLParser do
|
5
|
+
it 'decodes HTML entities, eg. less-than, greater-than signs' do
|
6
|
+
body = <<~XML
|
7
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
8
|
+
<YourMembership_Response>
|
9
|
+
<ErrCode>0</ErrCode>
|
10
|
+
<ExtendedErrorInfo><![CDATA[Text information here]]></ExtendedErrorInfo>
|
11
|
+
<Sa.Members.All.GetIDs>
|
12
|
+
<ServerGmtBias>-5</ServerGmtBias>
|
13
|
+
<ServerTime>2015-12-16 15:54:12</ServerTime>
|
14
|
+
<Members>
|
15
|
+
<ID>57EEB598-CB44-4D85-B0D6-377F393AF5B4</ID>
|
16
|
+
<ID>1C0CE647-FAA5-4EB0-ADF0-5B669B36378E</ID>
|
17
|
+
</Members>
|
18
|
+
</Sa.Members.All.GetIDs>
|
19
|
+
</YourMembership_Response>
|
20
|
+
XML
|
21
|
+
parser = described_class.new(body, :xml)
|
22
|
+
parsed = parser.parse
|
23
|
+
expect(parsed).to be_a(Hash)
|
24
|
+
ymr = parsed['YourMembership_Response']
|
25
|
+
expect(ymr['ErrCode']).to eq('0')
|
26
|
+
expect(ymr['ExtendedErrorInfo']).to eq('Text information here')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module YourMembership
|
4
|
+
RSpec.describe Base do
|
5
|
+
describe '.post' do
|
6
|
+
it 'uses YMXMLParser' do
|
7
|
+
mock_parser = instance_double(
|
8
|
+
::HTTParty::YMXMLParser,
|
9
|
+
parse: { 'YourMembership_Response' => { 'ErrCode' => 999 } }
|
10
|
+
)
|
11
|
+
allow(::HTTParty::YMXMLParser).to receive(:new).and_return(mock_parser)
|
12
|
+
# It doesn't matter which cassette we use for this test.
|
13
|
+
VCR.use_cassette 'sa_members_all_getids_timestamp_single' do
|
14
|
+
response = described_class.post('/')
|
15
|
+
expect(response).to be_an(::HTTParty::Response)
|
16
|
+
expect(response['YourMembership_Response']).to eq('ErrCode' => 999)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -77,6 +77,7 @@ describe YourMembership::Profile do
|
|
77
77
|
}
|
78
78
|
}
|
79
79
|
end
|
80
|
+
|
80
81
|
it "accepts and sets required parameters for new profiles" do
|
81
82
|
profile = YourMembership::Profile.create_new('afirstname', 'alastname', 'amembertypecode', 'aemail', 'ausername', 'apassword', {})
|
82
83
|
profile.data['FirstName'].should == 'afirstname'
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'dotenv'
|
2
|
-
require '
|
2
|
+
require 'byebug'
|
3
3
|
require 'vcr'
|
4
4
|
require 'your_membership'
|
5
|
+
require 'webmock/rspec'
|
5
6
|
|
6
7
|
Dotenv.load(
|
7
8
|
File.expand_path('../../.env.local', __FILE__),
|
@@ -98,4 +99,3 @@ YourMembership.configure(
|
|
98
99
|
privateKey: ENV.fetch('YM_API_PRIVATE_KEY'),
|
99
100
|
saPasscode: ENV.fetch('YM_API_SA_PASSCODE')
|
100
101
|
)
|
101
|
-
|
data/your_membership.gemspec
CHANGED
@@ -21,12 +21,12 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency "httparty", "
|
24
|
+
spec.add_dependency "httparty", ">=0.13.1", "<0.19"
|
25
25
|
spec.add_dependency "nokogiri", "~>1.6"
|
26
26
|
|
27
|
-
spec.add_development_dependency "bundler", "
|
27
|
+
spec.add_development_dependency "bundler", "<3"
|
28
|
+
spec.add_development_dependency "byebug"
|
28
29
|
spec.add_development_dependency "dotenv"
|
29
|
-
spec.add_development_dependency "pry"
|
30
30
|
spec.add_development_dependency "rake"
|
31
31
|
spec.add_development_dependency "rspec"
|
32
32
|
spec.add_development_dependency "vcr"
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: your_membership
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nate Flood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.13.1
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0.19'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 0.13.1
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.19'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: nokogiri
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,18 +48,18 @@ dependencies:
|
|
42
48
|
name: bundler
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- - "
|
51
|
+
- - "<"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
53
|
+
version: '3'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- - "
|
58
|
+
- - "<"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
60
|
+
version: '3'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
62
|
+
name: byebug
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - ">="
|
@@ -67,7 +73,7 @@ dependencies:
|
|
67
73
|
- !ruby/object:Gem::Version
|
68
74
|
version: '0'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
76
|
+
name: dotenv
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
79
|
- - ">="
|
@@ -155,7 +161,7 @@ files:
|
|
155
161
|
- LICENSE.txt
|
156
162
|
- README.md
|
157
163
|
- Rakefile
|
158
|
-
- lib/httparty/
|
164
|
+
- lib/httparty/ym_xml_parser.rb
|
159
165
|
- lib/your_membership.rb
|
160
166
|
- lib/your_membership/base.rb
|
161
167
|
- lib/your_membership/commerce.rb
|
@@ -184,6 +190,8 @@ files:
|
|
184
190
|
- spec/fixtures/vcr_cassettes/sa_members_all_getids_timestamp_multiple.yml
|
185
191
|
- spec/fixtures/vcr_cassettes/sa_members_all_getids_timestamp_none.yml
|
186
192
|
- spec/fixtures/vcr_cassettes/sa_members_all_getids_timestamp_single.yml
|
193
|
+
- spec/lib/httparty/ym_xml_parser_spec.rb
|
194
|
+
- spec/lib/your_membership/base_spec.rb
|
187
195
|
- spec/lib/your_membership/profile_spec.rb
|
188
196
|
- spec/lib/your_membership/sa_members_spec.rb
|
189
197
|
- spec/spec_helper.rb
|
@@ -207,8 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
215
|
- !ruby/object:Gem::Version
|
208
216
|
version: '0'
|
209
217
|
requirements: []
|
210
|
-
|
211
|
-
rubygems_version: 2.6.4
|
218
|
+
rubygems_version: 3.0.3
|
212
219
|
signing_key:
|
213
220
|
specification_version: 4
|
214
221
|
summary: Ruby SDK for interfacing with the YourMembership.com XML API
|
@@ -216,6 +223,8 @@ test_files:
|
|
216
223
|
- spec/fixtures/vcr_cassettes/sa_members_all_getids_timestamp_multiple.yml
|
217
224
|
- spec/fixtures/vcr_cassettes/sa_members_all_getids_timestamp_none.yml
|
218
225
|
- spec/fixtures/vcr_cassettes/sa_members_all_getids_timestamp_single.yml
|
226
|
+
- spec/lib/httparty/ym_xml_parser_spec.rb
|
227
|
+
- spec/lib/your_membership/base_spec.rb
|
219
228
|
- spec/lib/your_membership/profile_spec.rb
|
220
229
|
- spec/lib/your_membership/sa_members_spec.rb
|
221
230
|
- spec/spec_helper.rb
|
data/lib/httparty/patch.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
|
3
|
-
# Monkey Patch for the HTTParty Gem
|
4
|
-
module HTTParty
|
5
|
-
# In order to parse the HTML encoded documents returned by the YourMembership
|
6
|
-
# API we need to HTML decode the <![CDATA[ tags. This is a bug workaround.
|
7
|
-
class Request
|
8
|
-
# This is the encode_body method from HTTParty's Request Class adding an additional method call to fix
|
9
|
-
# the CDATA elements that are improperly formatted in the YourMembership API's XML. This is done here to ensure that
|
10
|
-
# the fix is in place before the data is parsed.
|
11
|
-
def encode_body(body)
|
12
|
-
body = fix_cdata body
|
13
|
-
if ''.respond_to?(:encoding)
|
14
|
-
_encode_body(body)
|
15
|
-
else
|
16
|
-
body
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# Bug Fix for HTML encoded < and > in XML body.
|
21
|
-
# @param body [String] an XML document that needs to be checked for this specific issue.
|
22
|
-
# @return [String] If the HTML encoding issue is found it is repaired and the document is returned.
|
23
|
-
def fix_cdata(body)
|
24
|
-
# <![CDATA[ = <![CDATA[
|
25
|
-
# ]]> = ]]>
|
26
|
-
if body.include? '<![CDATA['
|
27
|
-
body.gsub! '<![CDATA[', '<![CDATA['
|
28
|
-
body.gsub! ']]>', ']]>'
|
29
|
-
end
|
30
|
-
body
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|