Class: Me2API::API
- Inherits:
-
Object
- Object
- Me2API::API
- Defined in:
- lib/me2api/api.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
Instance Method Summary collapse
- #accept_friendship_request(friendship_request_id, message) ⇒ Object
- #create_comment(post_id, body) ⇒ Object
-
#create_post(user_id, body, options = {}) ⇒ Object
options :tag - 태그 :attachments - 첨부 파일.
- #delete_comment(comment_id) ⇒ Object
- #delete_post(post_id) ⇒ Object
- #friendship ⇒ Object
- #get_bands(options = {}) ⇒ Object
- #get_comments(post_id) ⇒ Object
- #get_friends(user_id, options = {}) ⇒ Object
- #get_friendship_requests(user_id) ⇒ Object
- #get_metoos(post_id) ⇒ Object
- #get_person(user_id) ⇒ Object
- #get_post(post_id) ⇒ Object
- #get_posts(user_id, options = {}) ⇒ Object
- #get_settings ⇒ Object
-
#initialize(options = {}) ⇒ API
constructor
A new instance of API.
- #metoo(post_id) ⇒ Object
- #noop ⇒ Object
- #track_comments(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ API
Returns a new instance of API.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/me2api/api.rb', line 7 def initialize( = {}) = { :appkey => nil, :user_id => nil, :apikey => nil, :logger => Logger.new(STDOUT) }.merge() @logger = [:logger] @agent = Agent.new( :appkey => [:appkey], :user_id => [:user_id], :apikey => [:apikey], :logger => @logger ) end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
5 6 7 |
# File 'lib/me2api/api.rb', line 5 def agent @agent end |
Instance Method Details
#accept_friendship_request(friendship_request_id, message) ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/me2api/api.rb', line 103 def accept_friendship_request(friendship_request_id, ) agent.call( 'accept_friendship_requests', :friendship_request_id => friendship_request_id, :message => ) end |
#create_comment(post_id, body) ⇒ Object
65 66 67 68 |
# File 'lib/me2api/api.rb', line 65 def create_comment(post_id, body) resp = agent.call('create_comment', :post_id => post_id, :body => body) Comment.new(post_id, resp) end |
#create_post(user_id, body, options = {}) ⇒ Object
options
:tag -
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/me2api/api.rb', line 42 def create_post(user_id, body, = {}) params = {} params['post[body]'] = body params['post[tag]'] = [:tag] if [:tag] if [:attachment] params[:files] = { 'attachment' => [:attachment] } end resp = agent.call("create_post/#{user_id}", params) Post.new(resp) end |
#delete_comment(comment_id) ⇒ Object
70 71 72 73 |
# File 'lib/me2api/api.rb', line 70 def delete_comment(comment_id) resp = agent.call('delete_comment', :comment_id => comment_id) Result.new(resp) end |
#delete_post(post_id) ⇒ Object
53 54 55 56 |
# File 'lib/me2api/api.rb', line 53 def delete_post(post_id) resp = agent.call("delete_post", :post_id => post_id) Result.new(resp) end |
#friendship ⇒ Object
94 95 96 |
# File 'lib/me2api/api.rb', line 94 def friendship raise NotImplementedError.new("friendship unsupported method") end |
#get_bands(options = {}) ⇒ Object
116 117 118 119 |
# File 'lib/me2api/api.rb', line 116 def get_bands( = {}) resp = agent.call('get_bands', ) resp.map { |b| Band.new(b) } end |
#get_comments(post_id) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/me2api/api.rb', line 58 def get_comments(post_id) resp = agent.call("get_comments", :post_id => post_id) resp['comments'].map do |c| Comment.new(post_id, c, :post_permalink => resp['post_permalink']) end end |
#get_friends(user_id, options = {}) ⇒ Object
89 90 91 92 |
# File 'lib/me2api/api.rb', line 89 def get_friends(user_id, = {}) resp = agent.call("get_friends/#{user_id}") resp['friends'].map { |f| Person.new(f) } end |
#get_friendship_requests(user_id) ⇒ Object
98 99 100 101 |
# File 'lib/me2api/api.rb', line 98 def get_friendship_requests(user_id) resp = agent.call("get_friendship_requests/#{user_id}") resp['friendship_requests'].map { |r| FriendshipRequest.new(r) } end |
#get_metoos(post_id) ⇒ Object
79 80 81 82 |
# File 'lib/me2api/api.rb', line 79 def get_metoos(post_id) resp = agent.call('get_metoos', :post_id => post_id) resp['metoos'].map { |m| Metoo.new(post_id, m) } end |
#get_person(user_id) ⇒ Object
24 25 26 27 |
# File 'lib/me2api/api.rb', line 24 def get_person(user_id) resp = agent.call("get_person/#{user_id}") Person.new(resp) end |
#get_post(post_id) ⇒ Object
29 30 31 32 |
# File 'lib/me2api/api.rb', line 29 def get_post(post_id) resp = agent.call("get_posts", :post_id => post_id) Post.new(resp.first) end |
#get_posts(user_id, options = {}) ⇒ Object
34 35 36 37 |
# File 'lib/me2api/api.rb', line 34 def get_posts(user_id, = {}) resp = agent.call("get_posts/#{user_id}", ) resp.map { |p| Post.new(p) } end |
#get_settings ⇒ Object
111 112 113 114 |
# File 'lib/me2api/api.rb', line 111 def get_settings resp = agent.call('get_settings') Setting.new(resp) end |
#metoo(post_id) ⇒ Object
84 85 86 87 |
# File 'lib/me2api/api.rb', line 84 def metoo(post_id) resp = agent.call('metoo', :post_id => post_id) Result.new(resp) end |
#noop ⇒ Object
121 122 123 124 |
# File 'lib/me2api/api.rb', line 121 def noop resp = agent.call('noop') Result.new(resp) end |
#track_comments(options = {}) ⇒ Object
75 76 77 |
# File 'lib/me2api/api.rb', line 75 def track_comments( = {}) raise NotImplementedError.new("track_comments unsupported method") end |