Skip to content

Commit

Permalink
Added a method to handle updating comments to network updates when th…
Browse files Browse the repository at this point in the history
…e update is commentable.

Created a post method as the update-comments api require a POST and not a PUT, even though the LinkedIn API says otherwise.

Created a method to convert the raw comment to the appropriate XML.

Modified the put method to accept a body and options.
  • Loading branch information
Josh Dennis authored and pengwynn committed Feb 21, 2010
1 parent 25834e2 commit 98297c3
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lib/linked_in/client.rb
Expand Up @@ -51,13 +51,20 @@ def get(path, options={})
response.body
end

def put(path, options={})
def put(path, body, options={})
path = "/v1#{path}"
response = access_token.put(path, options)
response = access_token.put(path, body, options)
raise_errors(response)
response
end

def post(path, body, options={})
path = "/v1#{path}"
response = access_token.post(path, body, options)
raise_errors(response)
response
end

def delete(path, options={})
path = "/v1#{path}"
response = access_token.delete(path, options)
Expand Down Expand Up @@ -112,6 +119,11 @@ def update_status(text)
path = "/people/~/current-status"
put(path, status_to_xml(text))
end

def update_comment(network_key, comment)
path = "/people/~/network/updates/key=#{network_key}/update-comments"
post(path,comment_to_xml(comment),{'Content-Type' => 'application/xml'})
end

def clear_status
path = "/people/~/current-status"
Expand Down Expand Up @@ -210,6 +222,9 @@ def status_to_xml(status)
<current-status>#{status}</current-status>}
end

def comment_to_xml(comment)
%Q{<?xml version="1.0" encoding="UTF-8"?><update-comment><comment>#{comment}</comment></update-comment>}
end

end
end
end

0 comments on commit 98297c3

Please sign in to comment.