rd_highrise_api 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 444d3f6f5d006d88942854bba150a4287f408d3e
4
+ data.tar.gz: c34c3d751110adb88e191f88865e2aa6b175c649
5
+ SHA512:
6
+ metadata.gz: 1247c6215c4bd26ff0162b4b8779724e0fc32ee3713682155b6361e74d56aaeb9b652e658a57b057b0106826d4661faab91a36ef0d643fbed298def1932ccc74
7
+ data.tar.gz: d76c74b6cd4829464bf06093d29018fed67d42150771f33fa12e25c117dcb3de204b8a2d1ca105b18a5450f3b9e5ce8e85b997e532595b74c6270a4f30c193d2
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rd_highrise_api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 André Luis Leal Cardoso Junior
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # RdHighriseApi
2
+
3
+ Simple gems that allows access to the Highrise API via http basic
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rd_highrise_api'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rd_highrise_api
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/rd_highrise_api/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rubocop/rake_task'
3
+ require 'ruby-lint/rake_task'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new
7
+
8
+ task :default => :spec
9
+ task :test => :spec
10
+
11
+ desc 'Run RuboCop on the lib directory'
12
+ Rubocop::RakeTask.new(:rubocop) do |task|
13
+ task.patterns = ['lib/**/*.rb']
14
+ # don't abort rake on failure
15
+ task.fail_on_error = false
16
+ end
17
+
18
+ RubyLint::RakeTask.new do |task|
19
+ task.name = 'lint'
20
+ task.files = ['lib']
21
+ end
22
+
23
+ desc 'Runs specs/Lint/Style checks'
24
+ task :all => [ :lint, :rubocop, :spec ]
@@ -0,0 +1,16 @@
1
+ module RdHighriseApi
2
+ # Methods used for parsing/connecting to highrise
3
+ module Api
4
+ def error_messages_from(body)
5
+ document = Nokogiri::XML(body)
6
+ document.xpath('//error').map(&:content)
7
+ end
8
+
9
+ def faraday
10
+ @faraday ||= Faraday.new(url: @url, ssl: { verify: false }) do |builder|
11
+ builder.basic_auth(@api_key, 'x')
12
+ builder.adapter Faraday.default_adapter
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,74 @@
1
+ require 'nokogiri'
2
+ require 'faraday'
3
+
4
+ module RdHighriseApi
5
+ # Reflects the People Api endpoint on Highrise
6
+ class People
7
+ include Api
8
+
9
+ def initialize(url, api_key)
10
+ @url = url
11
+ @api_key = api_key
12
+ end
13
+
14
+ def all
15
+ response = faraday.get('/people.xml')
16
+ fail ConnectionError if response.status != 200
17
+
18
+ document = Nokogiri.XML(response.body)
19
+ document.xpath('//person').map do |doc|
20
+ as_hash(doc)
21
+ end
22
+ end
23
+
24
+ def create(params)
25
+ response = faraday.post('/people.xml') do |request|
26
+ request.headers['Content-Type'] = 'application/xml'
27
+ request.body = as_xml(params)
28
+ end
29
+
30
+ {
31
+ status: 201,
32
+ messages: error_messages_from(response.body)
33
+ }
34
+ end
35
+
36
+ private
37
+
38
+ def as_xml(params)
39
+ builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
40
+ xml.person do
41
+ xml.contact_data do
42
+ xml.email_addresses do
43
+ xml.email_address do
44
+ xml.address params.delete(:email_address)
45
+ xml.location 'Work'
46
+ end
47
+ end
48
+ xml.phone_numbers do
49
+ xml.phone_number do
50
+ xml.number params.delete(:phone_number)
51
+ xml.location 'Work'
52
+ end
53
+ end
54
+ end
55
+
56
+ params.each do |key, value|
57
+ xml.send(key.to_s.gsub('_', '-'), value)
58
+ end
59
+ end
60
+ end
61
+ builder.to_xml
62
+ end
63
+
64
+ def as_hash(document)
65
+ {
66
+ first_name: document.at_xpath('first-name').content,
67
+ last_name: document.at_xpath('last-name').content,
68
+ title: document.at_xpath('title').content,
69
+ background: document.at_xpath('background').content,
70
+ linkedin_url: document.at_xpath('linkedin-url').content
71
+ }
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,4 @@
1
+ # Version
2
+ module RdHighriseApi
3
+ VERSION = '0.0.2'
4
+ end
@@ -0,0 +1,7 @@
1
+ require 'rd_highrise_api/version'
2
+ require 'rd_highrise_api/api'
3
+ require 'rd_highrise_api/people'
4
+
5
+ module RdHighriseApi
6
+ class ConnectionError < Exception; end
7
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rd_highrise_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rd_highrise_api"
8
+ spec.version = RdHighriseApi::VERSION
9
+ spec.authors = ["André Luis Leal Cardoso Junior"]
10
+ spec.email = ["andrehjr@gmail.com"]
11
+ spec.summary = %q{Access highrise api using Faraday}
12
+ spec.description = %q{Simple gem that allows to access Highrise api}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "faraday"
22
+ spec.add_dependency "nokogiri"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rubocop", "~> 0.18.1"
27
+ spec.add_development_dependency "ruby-lint", "~> 1.1.0"
28
+ spec.add_development_dependency "rspec", "~> 2.14"
29
+ spec.add_development_dependency "vcr"
30
+ spec.add_development_dependency "webmock"
31
+ end
@@ -0,0 +1,124 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://028bcc7b7986b72d4c9542dbbb1a85:x@andrehjr.highrisehq.com/people.xml
6
+ body:
7
+ encoding: UTF-8
8
+ string: |
9
+ <?xml version="1.0" encoding="UTF-8"?>
10
+ <person>
11
+ <contact_data>
12
+ <email_addresses>
13
+ <email_address>
14
+ <address>email@gmail.com</address>
15
+ <location>Work</location>
16
+ </email_address>
17
+ </email_addresses>
18
+ <phone_numbers>
19
+ <phone_number>
20
+ <number>1234-1234</number>
21
+ <location>Work</location>
22
+ </phone_number>
23
+ </phone_numbers>
24
+ </contact_data>
25
+ <first-name>Luke</first-name>
26
+ <last-name>Skywalker</last-name>
27
+ <title>Test title</title>
28
+ <company-name>Company!</company-name>
29
+ </person>
30
+ headers:
31
+ User-Agent:
32
+ - Faraday v0.9.0
33
+ Content-Type:
34
+ - application/xml
35
+ Accept-Encoding:
36
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
37
+ Accept:
38
+ - "*/*"
39
+ response:
40
+ status:
41
+ code: 201
42
+ message: Created
43
+ headers:
44
+ Server:
45
+ - nginx
46
+ Date:
47
+ - Thu, 17 Apr 2014 18:51:50 GMT
48
+ Content-Type:
49
+ - application/xml; charset=utf-8
50
+ Content-Length:
51
+ - '602'
52
+ Connection:
53
+ - Keep-Alive
54
+ Status:
55
+ - 201 Created
56
+ X-Throttle-Count:
57
+ - '1'
58
+ Location:
59
+ - https://andrehjr.highrisehq.com/people/205028539-luke-skywalker
60
+ X-Runtime:
61
+ - '232'
62
+ X-Frame-Options:
63
+ - SAMEORIGIN
64
+ X-Throttle-Horizon:
65
+ - '2014-04-17T18:52:00Z'
66
+ X-Throttle-Max:
67
+ - '500'
68
+ Cache-Control:
69
+ - no-cache
70
+ Set-Cookie:
71
+ - _sunrise_session=BAh7BzoPc2Vzc2lvbl9pZCIlODFkYmY5N2U3Njc3ZTZiYmNiNmVjMTA2ZTUwM2UwZmYiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7BjoPbmV3X3BlcnNvblQGOgpAdXNlZHsGOwdG--b9468ee639df61ec6938e1f731ff1ceddb82cd02;
72
+ path=/; HttpOnly; secure
73
+ Strict-Transport-Security:
74
+ - max-age=31536000
75
+ X-Request-Id:
76
+ - 3b34e575dae2d2be1c28075238b30ec1
77
+ Timing-Allow-Origin:
78
+ - "*"
79
+ Vary:
80
+ - Accept-Encoding
81
+ body:
82
+ encoding: UTF-8
83
+ string: |
84
+ <?xml version="1.0" encoding="UTF-8"?>
85
+ <person>
86
+ <author-id type="integer">1027612</author-id>
87
+ <background nil="true"></background>
88
+ <company-id type="integer" nil="true"></company-id>
89
+ <created-at type="datetime">2014-04-17T18:51:50Z</created-at>
90
+ <first-name>Luke</first-name>
91
+ <group-id type="integer" nil="true"></group-id>
92
+ <id type="integer">205028539</id>
93
+ <last-name>Skywalker</last-name>
94
+ <owner-id type="integer" nil="true"></owner-id>
95
+ <title>Test title</title>
96
+ <updated-at type="datetime">2014-04-17T18:51:50Z</updated-at>
97
+ <visible-to>Everyone</visible-to>
98
+ <company-name nil="true"></company-name>
99
+ <linkedin-url nil="true"></linkedin-url>
100
+ <avatar-url>http://dge9rmgqjs8m1.cloudfront.net/highrise/missing/avatar.gif?r=3</avatar-url>
101
+ <contact-data>
102
+ <instant-messengers type="array"/>
103
+ <twitter-accounts type="array"/>
104
+ <email-addresses type="array">
105
+ <email-address>
106
+ <address>email@gmail.com</address>
107
+ <id type="integer">104808353</id>
108
+ <location>Work</location>
109
+ </email-address>
110
+ </email-addresses>
111
+ <phone-numbers type="array">
112
+ <phone-number>
113
+ <id type="integer">165962837</id>
114
+ <location>Work</location>
115
+ <number>1234-1234</number>
116
+ </phone-number>
117
+ </phone-numbers>
118
+ <addresses type="array"/>
119
+ <web-addresses type="array"/>
120
+ </contact-data>
121
+ </person>
122
+ http_version:
123
+ recorded_at: Thu, 17 Apr 2014 18:54:44 GMT
124
+ recorded_with: VCR 2.9.0
@@ -0,0 +1,76 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://028bcc7b7986b72d4c9542dbbb1a85:x@andrehjr.highrisehq.com/people.xml
6
+ body:
7
+ encoding: UTF-8
8
+ string: |
9
+ <?xml version="1.0" encoding="UTF-8"?>
10
+ <person>
11
+ <contact_data>
12
+ <email_addresses>
13
+ <email_address>
14
+ <address/>
15
+ </email_address>
16
+ </email_addresses>
17
+ <phone_numbers>
18
+ <phone_number>
19
+ <number/>
20
+ </phone_number>
21
+ </phone_numbers>
22
+ </contact_data>
23
+ <last-name>Skywalker</last-name>
24
+ <title>Test title</title>
25
+ <background>A background</background>
26
+ </person>
27
+ headers:
28
+ User-Agent:
29
+ - Faraday v0.9.0
30
+ Content-Type:
31
+ - application/xml
32
+ Accept-Encoding:
33
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
34
+ Accept:
35
+ - "*/*"
36
+ response:
37
+ status:
38
+ code: 422
39
+ message: Unprocessable Entity
40
+ headers:
41
+ Server:
42
+ - nginx
43
+ Date:
44
+ - Thu, 17 Apr 2014 18:48:26 GMT
45
+ Content-Type:
46
+ - application/xml; charset=utf-8
47
+ Content-Length:
48
+ - '101'
49
+ Connection:
50
+ - keep-alive
51
+ Status:
52
+ - 422 Unprocessable Entity
53
+ X-Throttle-Count:
54
+ - '2'
55
+ X-Frame-Options:
56
+ - SAMEORIGIN
57
+ X-Throttle-Horizon:
58
+ - '2014-04-17T18:48:30Z'
59
+ X-Throttle-Max:
60
+ - '500'
61
+ Cache-Control:
62
+ - no-cache
63
+ Strict-Transport-Security:
64
+ - max-age=31536000
65
+ X-Request-Id:
66
+ - fabe8c5918f93dac3ca6e40b849ced10
67
+ body:
68
+ encoding: UTF-8
69
+ string: |
70
+ <?xml version="1.0" encoding="UTF-8"?>
71
+ <errors>
72
+ <error>First name can't be blank</error>
73
+ </errors>
74
+ http_version:
75
+ recorded_at: Thu, 17 Apr 2014 18:51:19 GMT
76
+ recorded_with: VCR 2.9.0
@@ -0,0 +1,188 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://028bcc7b7986b72d4c9542dbbb1a85:x@andrehjr.highrisehq.com/people.xml
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Thu, 17 Apr 2014 18:48:17 GMT
25
+ Content-Type:
26
+ - application/xml; charset=utf-8
27
+ Content-Length:
28
+ - '851'
29
+ Connection:
30
+ - Keep-Alive
31
+ Status:
32
+ - 200 OK
33
+ X-Runtime:
34
+ - '58'
35
+ Strict-Transport-Security:
36
+ - max-age=31536000
37
+ X-Request-Id:
38
+ - 4ccb466730c826402cd8a56bc57245bb
39
+ X-Throttle-Max:
40
+ - '500'
41
+ Cache-Control:
42
+ - private, max-age=0, must-revalidate
43
+ X-Frame-Options:
44
+ - SAMEORIGIN
45
+ Etag:
46
+ - '"2d71c8678c8ef4612359e8330b284c3f"'
47
+ X-Throttle-Horizon:
48
+ - '2014-04-17T18:48:20Z'
49
+ X-Throttle-Count:
50
+ - '1'
51
+ Timing-Allow-Origin:
52
+ - "*"
53
+ Vary:
54
+ - Accept-Encoding
55
+ body:
56
+ encoding: UTF-8
57
+ string: |
58
+ <?xml version="1.0" encoding="UTF-8"?>
59
+ <people type="array">
60
+ <person>
61
+ <author-id type="integer">1027612</author-id>
62
+ <background nil="true"></background>
63
+ <company-id type="integer" nil="true"></company-id>
64
+ <created-at type="datetime">2014-04-17T16:39:21Z</created-at>
65
+ <first-name>asdf</first-name>
66
+ <group-id type="integer" nil="true"></group-id>
67
+ <id type="integer">205009737</id>
68
+ <last-name nil="true"></last-name>
69
+ <owner-id type="integer" nil="true"></owner-id>
70
+ <title nil="true"></title>
71
+ <updated-at type="datetime">2014-04-17T16:39:21Z</updated-at>
72
+ <visible-to>Everyone</visible-to>
73
+ <company-name nil="true"></company-name>
74
+ <linkedin-url nil="true"></linkedin-url>
75
+ <avatar-url>http://dge9rmgqjs8m1.cloudfront.net/highrise/missing/avatar.gif?r=3</avatar-url>
76
+ <contact-data>
77
+ <instant-messengers type="array"/>
78
+ <twitter-accounts type="array"/>
79
+ <email-addresses type="array"/>
80
+ <phone-numbers type="array"/>
81
+ <addresses type="array"/>
82
+ <web-addresses type="array"/>
83
+ </contact-data>
84
+ </person>
85
+ <person>
86
+ <author-id type="integer">1027612</author-id>
87
+ <background></background>
88
+ <company-id type="integer">204932209</company-id>
89
+ <created-at type="datetime">2014-04-16T23:45:03Z</created-at>
90
+ <first-name>Andr&#233; L.</first-name>
91
+ <group-id type="integer" nil="true"></group-id>
92
+ <id type="integer">204932208</id>
93
+ <last-name>Leal Cardoso Jr</last-name>
94
+ <owner-id type="integer" nil="true"></owner-id>
95
+ <title>Ruby Developer</title>
96
+ <updated-at type="datetime">2014-04-16T23:45:03Z</updated-at>
97
+ <visible-to>Everyone</visible-to>
98
+ <company-name>37 Signals</company-name>
99
+ <linkedin-url nil="true"></linkedin-url>
100
+ <avatar-url>http://dge9rmgqjs8m1.cloudfront.net/highrise/missing/avatar.gif?r=3</avatar-url>
101
+ <contact-data>
102
+ <instant-messengers type="array"/>
103
+ <twitter-accounts type="array"/>
104
+ <email-addresses type="array"/>
105
+ <phone-numbers type="array"/>
106
+ <addresses type="array"/>
107
+ <web-addresses type="array"/>
108
+ </contact-data>
109
+ </person>
110
+ <person>
111
+ <author-id type="integer">1027612</author-id>
112
+ <background nil="true"></background>
113
+ <company-id type="integer" nil="true"></company-id>
114
+ <created-at type="datetime">2014-04-17T17:08:22Z</created-at>
115
+ <first-name>Omg</first-name>
116
+ <group-id type="integer" nil="true"></group-id>
117
+ <id type="integer">205020563</id>
118
+ <last-name nil="true"></last-name>
119
+ <owner-id type="integer" nil="true"></owner-id>
120
+ <title nil="true"></title>
121
+ <updated-at type="datetime">2014-04-17T17:08:22Z</updated-at>
122
+ <visible-to>Everyone</visible-to>
123
+ <company-name nil="true"></company-name>
124
+ <linkedin-url nil="true"></linkedin-url>
125
+ <avatar-url>http://dge9rmgqjs8m1.cloudfront.net/highrise/missing/avatar.gif?r=3</avatar-url>
126
+ <contact-data>
127
+ <instant-messengers type="array"/>
128
+ <twitter-accounts type="array"/>
129
+ <email-addresses type="array"/>
130
+ <phone-numbers type="array"/>
131
+ <addresses type="array"/>
132
+ <web-addresses type="array"/>
133
+ </contact-data>
134
+ </person>
135
+ <person>
136
+ <author-id type="integer">1027612</author-id>
137
+ <background>A background</background>
138
+ <company-id type="integer" nil="true"></company-id>
139
+ <created-at type="datetime">2014-04-17T13:40:55Z</created-at>
140
+ <first-name>Luke</first-name>
141
+ <group-id type="integer" nil="true"></group-id>
142
+ <id type="integer">204970862</id>
143
+ <last-name>Skywalker</last-name>
144
+ <owner-id type="integer" nil="true"></owner-id>
145
+ <title>Test title</title>
146
+ <updated-at type="datetime">2014-04-17T13:40:55Z</updated-at>
147
+ <visible-to>Everyone</visible-to>
148
+ <company-name nil="true"></company-name>
149
+ <linkedin-url nil="true"></linkedin-url>
150
+ <avatar-url>http://dge9rmgqjs8m1.cloudfront.net/highrise/missing/avatar.gif?r=3</avatar-url>
151
+ <contact-data>
152
+ <instant-messengers type="array"/>
153
+ <twitter-accounts type="array"/>
154
+ <email-addresses type="array"/>
155
+ <phone-numbers type="array"/>
156
+ <addresses type="array"/>
157
+ <web-addresses type="array"/>
158
+ </contact-data>
159
+ </person>
160
+ <person>
161
+ <author-id type="integer">1027612</author-id>
162
+ <background nil="true"></background>
163
+ <company-id type="integer" nil="true"></company-id>
164
+ <created-at type="datetime">2014-04-17T18:04:33Z</created-at>
165
+ <first-name>Mark</first-name>
166
+ <group-id type="integer" nil="true"></group-id>
167
+ <id type="integer">205025189</id>
168
+ <last-name>Zuckerberg</last-name>
169
+ <owner-id type="integer" nil="true"></owner-id>
170
+ <title>Title title</title>
171
+ <updated-at type="datetime">2014-04-17T18:04:33Z</updated-at>
172
+ <visible-to>Everyone</visible-to>
173
+ <company-name nil="true"></company-name>
174
+ <linkedin-url nil="true"></linkedin-url>
175
+ <avatar-url>http://dge9rmgqjs8m1.cloudfront.net/highrise/missing/avatar.gif?r=3</avatar-url>
176
+ <contact-data>
177
+ <instant-messengers type="array"/>
178
+ <twitter-accounts type="array"/>
179
+ <email-addresses type="array"/>
180
+ <phone-numbers type="array"/>
181
+ <addresses type="array"/>
182
+ <web-addresses type="array"/>
183
+ </contact-data>
184
+ </person>
185
+ </people>
186
+ http_version:
187
+ recorded_at: Thu, 17 Apr 2014 18:51:10 GMT
188
+ recorded_with: VCR 2.9.0
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ class Test; include RdHighriseApi::Api; end
4
+
5
+ describe RdHighriseApi::Api do
6
+ let(:xml) { "<errors><error>First name can't be blank</error><error>Last name can't be blank</error></errors>"}
7
+
8
+ it "should parse error messages correctly" do
9
+ expect(Test.new.error_messages_from(xml)).to eql(["First name can't be blank", "Last name can't be blank"])
10
+ end
11
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe RdHighriseApi::People do
4
+ let(:api) { RdHighriseApi::People.new('https://andrehjr.highrisehq.com', '028bcc7b7986b72d4c9542dbbb1a85') }
5
+ let(:valid_params) { { first_name: "Luke", last_name: 'Skywalker', title: 'Test title', company_name: 'Company!',
6
+ phone_number: '1234-1234', email_address: 'email@gmail.com'} }
7
+
8
+ it "should fetch people from highrise" do
9
+ VCR.use_cassette('list') do
10
+ people = api.all
11
+ expect(people).to be_a(Array)
12
+ end
13
+ end
14
+
15
+ it "should parse person xml data from highrise correctly" do
16
+ VCR.use_cassette('list') do
17
+ person = api.all.last
18
+ expect(person.keys).to include(:first_name, :last_name)
19
+ expect(person[:first_name]).to eql("Mark")
20
+ end
21
+ end
22
+
23
+ it "should generate a person xml from parameters" do
24
+ VCR.use_cassette('create') do
25
+ response = api.create(valid_params)
26
+ expect(response[:status]).to eql(201)
27
+ end
28
+ end
29
+
30
+ it "should fail a person does't have the required parameters" do
31
+ VCR.use_cassette('create_failing') do
32
+ response = api.create(last_name: 'Skywalker', title: 'Test title', background: 'A background')
33
+ expect(response[:messages]).to include("First name can't be blank")
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,16 @@
1
+ require './lib/rd_highrise_api'
2
+
3
+ require 'vcr'
4
+
5
+ VCR.configure do |c|
6
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
7
+ c.hook_into :webmock # or :fakeweb
8
+ end
9
+
10
+ RSpec.configure do |config|
11
+ config.mock_with :rspec
12
+ config.color_enabled = true
13
+ config.tty = true
14
+
15
+ config.formatter = :documentation # :progress, :html, :textmate
16
+ end
metadata ADDED
@@ -0,0 +1,192 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rd_highrise_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - André Luis Leal Cardoso Junior
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
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: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.18.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.18.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: ruby-lint
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.1.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.14'
111
+ - !ruby/object:Gem::Dependency
112
+ name: vcr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Simple gem that allows to access Highrise api
140
+ email:
141
+ - andrehjr@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - Gemfile
148
+ - LICENSE.txt
149
+ - README.md
150
+ - Rakefile
151
+ - lib/rd_highrise_api.rb
152
+ - lib/rd_highrise_api/api.rb
153
+ - lib/rd_highrise_api/people.rb
154
+ - lib/rd_highrise_api/version.rb
155
+ - rd_highrise_api.gemspec
156
+ - spec/fixtures/vcr_cassettes/create.yml
157
+ - spec/fixtures/vcr_cassettes/create_failing.yml
158
+ - spec/fixtures/vcr_cassettes/list.yml
159
+ - spec/rd_highrise_api/api_spec.rb
160
+ - spec/rd_highrise_api/people_spec.rb
161
+ - spec/spec_helper.rb
162
+ homepage: ''
163
+ licenses:
164
+ - MIT
165
+ metadata: {}
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 2.2.2
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: Access highrise api using Faraday
186
+ test_files:
187
+ - spec/fixtures/vcr_cassettes/create.yml
188
+ - spec/fixtures/vcr_cassettes/create_failing.yml
189
+ - spec/fixtures/vcr_cassettes/list.yml
190
+ - spec/rd_highrise_api/api_spec.rb
191
+ - spec/rd_highrise_api/people_spec.rb
192
+ - spec/spec_helper.rb