linkedin-idkmybffjill 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source :gemcutter
2
2
 
3
3
  gem 'oauth', '~> 0.3.5'
4
- gem 'nokogiri'
4
+ gem 'nokogiri', '~> 1.4.4'
5
5
  gem 'crack', '>= 0.1.4'
6
6
 
7
7
  group :development do
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.9
1
+ 0.2.0
@@ -60,6 +60,8 @@ module LinkedIn
60
60
  def post(path, body='', options={})
61
61
  path = "/v1#{path}"
62
62
  response = access_token.post(path, body, options)
63
+ puts 'response:'
64
+ puts response
63
65
  raise_errors(response)
64
66
  response
65
67
  end
@@ -157,14 +159,53 @@ module LinkedIn
157
159
  recipients.recipients = recipient_paths.map do |profile_path|
158
160
  recipient = LinkedIn::Recipient.new
159
161
  recipient.person = LinkedIn::Person.new
160
- recipient.person.path = "/people/#{profile_path}"
162
+ recipient.person.path = "\"/people/#{profile_path}\""
161
163
  recipient
162
164
  end
163
165
 
164
166
  message.recipients = recipients
167
+
168
+ puts 'sending in send_message:'
169
+ puts path
170
+ puts message_to_xml(message)
171
+
172
+
173
+ post(path, message_to_xml(message), { "Content-Type" => "text/xml" }).code
174
+ end
175
+
176
+
177
+ def send_invite(subject, body, recipient_paths)
178
+ path = "/people/~/mailbox"
179
+
180
+ message = LinkedIn::InviteMessage.new
181
+ message.subject = subject
182
+ message.body = body
183
+ recipients = LinkedIn::Recipients.new
184
+
185
+ recipients.recipients = recipient_paths.map do |recipient_hash|
186
+ email = recipient_hash[:email]
187
+ first = recipient_hash[:first]
188
+ last = recipient_hash[:last]
189
+ recipient = LinkedIn::Recipient.new
190
+ recipient.person = LinkedIn::Person.new
191
+ recipient.person.path = "\"/people/email=#{email}\""
192
+ recipient.person.first_name = first
193
+ recipient.person.last_name = last
194
+ recipient
195
+ end
196
+
197
+ message.recipients = recipients
198
+
199
+ puts 'sending in send_message:'
200
+ puts path
201
+ puts message_to_xml(message)
202
+
203
+
165
204
  post(path, message_to_xml(message), { "Content-Type" => "text/xml" }).code
166
205
  end
167
206
 
207
+
208
+
168
209
  def network_statuses(options={})
169
210
  options[:type] = 'STAT'
170
211
  network_updates(options)
@@ -5,27 +5,64 @@ module LinkedIn
5
5
 
6
6
  def to_xml
7
7
  "<mailbox-item>
8
- <recipients>
9
- #{recipients.to_xml}
10
- </recipients>
8
+ #{recipients.to_xml}
11
9
  <subject>#{subject}</subject>
12
10
  <body>#{body}</body>
13
11
  </mailbox-item>"
14
12
  end
15
13
 
14
+ # <mailbox-item>
15
+ # <recipients>
16
+ # <recipient>
17
+ # <person path='/people/~'/>
18
+ # </recipient>
19
+ # <recipient>
20
+ # <person path="/people/abcdefg" />
21
+ # </recipient>
22
+ # </recipients>
23
+ # <subject>Congratulations on your new position.</subject>
24
+ # <body>You're certainly the best person for the job!</body>
25
+ # </mailbox-item>
26
+
27
+ end
28
+
29
+ class InviteMessage < Message
30
+
31
+ def to_xml
32
+ invitation_type = "friend"
33
+
34
+ "<mailbox-item>
35
+ #{recipients.to_xml}
36
+ <subject>#{subject}</subject>
37
+ <body>#{body}</body>
38
+ <item-content>
39
+ <invitation-request>
40
+ <connect-type>#{invitation_type}</connect-type>
41
+ </invitation-request>
42
+ </item-content>
43
+ </mailbox-item>"
44
+ end
45
+
46
+ # <mailbox-item>
47
+ # <recipients>
48
+ # <recipient>
49
+ # <person path="/people/email=a_user@domain.com">
50
+ # <first-name>Richard</first-name>
51
+ # <last-name>Brautigan</last-name>
52
+ # </person>
53
+ # </recipient>
54
+ # </recipients>
55
+ # <subject>Invitation to Connect</subject>
56
+ # <body>Please join my professional network on LinkedIn.</body>
57
+ # <item-content>
58
+ # <invitation-request>
59
+ # <connect-type>friend</connect-type>
60
+ # </invitation-request>
61
+ # </item-content>
62
+ # </mailbox-item>
63
+
16
64
  end
17
65
 
18
66
  end
19
67
 
20
- # <mailbox-item>
21
- # <recipients>
22
- # <recipient>
23
- # <person path='/people/~'/>
24
- # </recipient>
25
- # <recipient>
26
- # <person path="/people/abcdefg" />
27
- # </recipient>
28
- # </recipients>
29
- # <subject>Congratulations on your new position.</subject>
30
- # <body>You're certainly the best person for the job!</body>
31
- # </mailbox-item>
68
+
@@ -1,7 +1,26 @@
1
1
  module LinkedIn
2
2
  class Person
3
3
 
4
- attr_accessor :path
4
+ attr_accessor :path, :first_name, :last_name
5
+
6
+ def to_xml
7
+ str = ''
8
+
9
+ if first_name != nil || last_name != nil
10
+ str << "<person path=#{path}>"
11
+ if first_name != nil
12
+ str << "<first-name>#{first_name}</first-name>"
13
+ end
14
+ if last_name != nil
15
+ str << "<last-name>#{last_name}</last-name>"
16
+ end
17
+ str << "</person>"
18
+ else
19
+ str << "<person path=#{path}/>"
20
+ end
21
+
22
+ str
23
+ end
5
24
 
6
25
  end
7
26
  end
@@ -3,5 +3,12 @@ module LinkedIn
3
3
 
4
4
  attr_accessor :person
5
5
 
6
+ def to_xml
7
+ str = ''
8
+
9
+ str << "<recipient>#{person.to_xml}</recipient>"
10
+
11
+ str
12
+ end
6
13
  end
7
14
  end
@@ -4,10 +4,11 @@ module LinkedIn
4
4
  attr_accessor :recipients
5
5
 
6
6
  def to_xml
7
- str = ''
7
+ str = '<recipients>'
8
8
  recipients.each do |recipient|
9
- str << "<recipient><person path=#{recipient.person.path}/></recipient>"
9
+ str << "#{recipient.to_xml}"
10
10
  end
11
+ str << "</recipients>"
11
12
  str
12
13
  end
13
14
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linkedin-idkmybffjill
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
5
- prerelease: false
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 9
10
- version: 0.1.9
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Wynn Netherland, idkmybffjill
@@ -35,9 +35,25 @@ dependencies:
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: crack
38
+ name: nokogiri
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 15
46
+ segments:
47
+ - 1
48
+ - 4
49
+ - 4
50
+ version: 1.4.4
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: crack
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
41
57
  none: false
42
58
  requirements:
43
59
  - - ~>
@@ -49,11 +65,11 @@ dependencies:
49
65
  - 4
50
66
  version: 0.1.4
51
67
  type: :runtime
52
- version_requirements: *id002
68
+ version_requirements: *id003
53
69
  - !ruby/object:Gem::Dependency
54
70
  name: shoulda
55
71
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
72
+ requirement: &id004 !ruby/object:Gem::Requirement
57
73
  none: false
58
74
  requirements:
59
75
  - - ">="
@@ -65,11 +81,11 @@ dependencies:
65
81
  - 1
66
82
  version: 2.10.1
67
83
  type: :development
68
- version_requirements: *id003
84
+ version_requirements: *id004
69
85
  - !ruby/object:Gem::Dependency
70
86
  name: jnunemaker-matchy
71
87
  prerelease: false
72
- requirement: &id004 !ruby/object:Gem::Requirement
88
+ requirement: &id005 !ruby/object:Gem::Requirement
73
89
  none: false
74
90
  requirements:
75
91
  - - "="
@@ -81,11 +97,11 @@ dependencies:
81
97
  - 0
82
98
  version: 0.4.0
83
99
  type: :development
84
- version_requirements: *id004
100
+ version_requirements: *id005
85
101
  - !ruby/object:Gem::Dependency
86
102
  name: mocha
87
103
  prerelease: false
88
- requirement: &id005 !ruby/object:Gem::Requirement
104
+ requirement: &id006 !ruby/object:Gem::Requirement
89
105
  none: false
90
106
  requirements:
91
107
  - - ">="
@@ -97,11 +113,11 @@ dependencies:
97
113
  - 4
98
114
  version: 0.9.4
99
115
  type: :development
100
- version_requirements: *id005
116
+ version_requirements: *id006
101
117
  - !ruby/object:Gem::Dependency
102
118
  name: fakeweb
103
119
  prerelease: false
104
- requirement: &id006 !ruby/object:Gem::Requirement
120
+ requirement: &id007 !ruby/object:Gem::Requirement
105
121
  none: false
106
122
  requirements:
107
123
  - - ">="
@@ -113,7 +129,7 @@ dependencies:
113
129
  - 5
114
130
  version: 1.2.5
115
131
  type: :development
116
- version_requirements: *id006
132
+ version_requirements: *id007
117
133
  description: Ruby wrapper for the LinkedIn API
118
134
  email: wynn.netherland@gmail.com
119
135
  executables: []
@@ -200,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
216
  requirements: []
201
217
 
202
218
  rubyforge_project:
203
- rubygems_version: 1.3.7
219
+ rubygems_version: 1.4.2
204
220
  signing_key:
205
221
  specification_version: 3
206
222
  summary: Ruby wrapper for the LinkedIn API