Class: Ayadn::Endpoints

Inherits:
Object
  • Object
show all
Defined in:
lib/ayadn/endpoints.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEndpoints

Returns a new instance of Endpoints.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ayadn/endpoints.rb', line 7

def initialize
  @ayadn_callback_url = "http://aya.io/ayadn/auth.html"
  @base_url = "https://api.app.net/"
  @config_api_url = @base_url + "config"
  @posts_url = @base_url + "posts/"
  @users_url = @base_url + "users/"
  @files_url = @base_url + "files/"
  @token_url = @base_url + "token/"
  @channels_url = @base_url + "channels/"
  @pm_url = @channels_url + "pm/messages"
end

Instance Attribute Details

#ayadn_callback_urlObject

Returns the value of attribute ayadn_callback_url.



5
6
7
# File 'lib/ayadn/endpoints.rb', line 5

def ayadn_callback_url
  @ayadn_callback_url
end

#base_urlObject

Returns the value of attribute base_url.



5
6
7
# File 'lib/ayadn/endpoints.rb', line 5

def base_url
  @base_url
end

#channels_urlObject

Returns the value of attribute channels_url.



5
6
7
# File 'lib/ayadn/endpoints.rb', line 5

def channels_url
  @channels_url
end

#config_api_urlObject

Returns the value of attribute config_api_url.



5
6
7
# File 'lib/ayadn/endpoints.rb', line 5

def config_api_url
  @config_api_url
end

#files_urlObject

Returns the value of attribute files_url.



5
6
7
# File 'lib/ayadn/endpoints.rb', line 5

def files_url
  @files_url
end

#pm_urlObject

Returns the value of attribute pm_url.



5
6
7
# File 'lib/ayadn/endpoints.rb', line 5

def pm_url
  @pm_url
end

#posts_urlObject

Returns the value of attribute posts_url.



5
6
7
# File 'lib/ayadn/endpoints.rb', line 5

def posts_url
  @posts_url
end

#token_urlObject

Returns the value of attribute token_url.



5
6
7
# File 'lib/ayadn/endpoints.rb', line 5

def token_url
  @token_url
end

#users_urlObject

Returns the value of attribute users_url.



5
6
7
# File 'lib/ayadn/endpoints.rb', line 5

def users_url
  @users_url
end

Instance Method Details

#authorize_urlObject



19
20
21
# File 'lib/ayadn/endpoints.rb', line 19

def authorize_url
  "https://account.app.net/oauth/authenticate?client_id=#{Settings::AYADN_CLIENT_ID}&response_type=token&redirect_uri=#{@ayadn_callback_url}&scope=basic,stream,write_post,follow,public_messages,messages,files,update_profile&include_marker=1"
end

#avatarObject



267
268
269
# File 'lib/ayadn/endpoints.rb', line 267

def avatar
  "#{@users_url}me/avatar"
end

#block(username) ⇒ Object



243
244
245
# File 'lib/ayadn/endpoints.rb', line 243

def block(username)
  "#{@users_url}#{username}/block?access_token=#{Settings.user_token}"
end

#blocked(options) ⇒ Object



157
158
159
# File 'lib/ayadn/endpoints.rb', line 157

def blocked(options)
  "#{@users_url}me/blocked/?access_token=#{Settings.user_token}&count=#{options[:count]}&before_id=#{options[:before_id]}"
end

#channel(channel_id, options = {}) ⇒ Object



259
260
261
# File 'lib/ayadn/endpoints.rb', line 259

def channel(channel_id, options = {})
  "#{@channels_url}?ids=#{channel_id.join(',')}&access_token=#{Settings.user_token}#{API.build_query(options)}&include_marker=1"
end

#channels(options) ⇒ Object



255
256
257
# File 'lib/ayadn/endpoints.rb', line 255

def channels(options)
  "#{@channels_url}?access_token=#{Settings.user_token}#{API.build_query(options)}"
end

#checkins(options) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/ayadn/endpoints.rb', line 44

def checkins(options)
  @options_list = if options[:count] || options[:since_id]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:checkins]})
  end
  "#{@posts_url}stream/explore/checkins?access_token=#{Settings.user_token}#{@options_list}"
end

#conversations(options) ⇒ Object



84
85
86
87
88
89
90
91
# File 'lib/ayadn/endpoints.rb', line 84

def conversations(options)
  @options_list = if options[:count] || options[:since_id]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:conversations]})
  end
  "#{@posts_url}stream/explore/conversations?access_token=#{Settings.user_token}#{@options_list}"
end

#convo(post_id, options) ⇒ Object



136
137
138
139
140
141
142
143
# File 'lib/ayadn/endpoints.rb', line 136

def convo(post_id, options)
  @options_list = if options[:count]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:convo]})
  end
  "#{@posts_url}#{post_id}/replies/?access_token=#{Settings.user_token}#{@options_list}"
end

#coverObject



271
272
273
# File 'lib/ayadn/endpoints.rb', line 271

def cover
  "#{@users_url}me/cover"
end

#delete_message(channel_id, message_id) ⇒ Object



231
232
233
# File 'lib/ayadn/endpoints.rb', line 231

def delete_message(channel_id, message_id)
  "#{@channels_url}/#{channel_id}/messages/#{message_id}?access_token=#{Settings.user_token}"
end

#delete_post(post_id) ⇒ Object



227
228
229
# File 'lib/ayadn/endpoints.rb', line 227

def delete_post(post_id)
  "#{@posts_url}#{post_id}?access_token=#{Settings.user_token}"
end

#file(file_id) ⇒ Object



27
28
29
# File 'lib/ayadn/endpoints.rb', line 27

def file(file_id)
  "#{@files_url}#{file_id}?access_token=#{Settings.user_token}"
end

#filesObject



31
32
33
# File 'lib/ayadn/endpoints.rb', line 31

def files
  "#{@files_url}?access_token=#{Settings.user_token}"
end

#files_list(options) ⇒ Object



218
219
220
221
222
223
224
225
# File 'lib/ayadn/endpoints.rb', line 218

def files_list(options)
  @options_list = if options[:count]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:files]})
  end
  "#{@users_url}me/files?access_token=#{Settings.user_token}#{@options_list}"
end

#follow(username) ⇒ Object



235
236
237
# File 'lib/ayadn/endpoints.rb', line 235

def follow(username)
  "#{@users_url}#{username}/follow?access_token=#{Settings.user_token}"
end

#followers(username, options) ⇒ Object



149
150
151
# File 'lib/ayadn/endpoints.rb', line 149

def followers(username, options)
  "#{@users_url}#{username}/followers/?access_token=#{Settings.user_token}&count=#{options[:count]}&before_id=#{options[:before_id]}"
end

#followings(username, options) ⇒ Object



145
146
147
# File 'lib/ayadn/endpoints.rb', line 145

def followings(username, options)
  "#{@users_url}#{username}/following/?access_token=#{Settings.user_token}&count=#{options[:count]}&before_id=#{options[:before_id]}"
end

#global(options) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ayadn/endpoints.rb', line 53

def global(options)
  @options_list = if options[:count] || options[:since_id]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:global]})
  end
  if Settings.global[:force] == true
    "#{@posts_url}stream/global?#{@options_list}"
  else
    "#{@posts_url}stream/global?access_token=#{Settings.user_token}#{@options_list}"
  end
end

#hashtag(hashtag) ⇒ Object



161
162
163
# File 'lib/ayadn/endpoints.rb', line 161

def hashtag(hashtag)
  "#{@posts_url}tag/#{hashtag}"
end

#interactionsObject



124
125
126
# File 'lib/ayadn/endpoints.rb', line 124

def interactions
  "#{@users_url}me/interactions?access_token=#{Settings.user_token}"
end

#mentions(username, options) ⇒ Object



93
94
95
96
97
98
99
100
# File 'lib/ayadn/endpoints.rb', line 93

def mentions(username, options)
  @options_list = if options[:count]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:mentions]})
  end
  "#{@users_url}#{username}/mentions/?access_token=#{Settings.user_token}#{@options_list}"
end

#messages(channel_id, options = {}) ⇒ Object



263
264
265
# File 'lib/ayadn/endpoints.rb', line 263

def messages(channel_id, options = {})
  "#{@channels_url}#{channel_id}/messages?access_token=#{Settings.user_token}#{API.build_query(options)}&include_machine=1&include_marker=1"
end

#mute(username) ⇒ Object



239
240
241
# File 'lib/ayadn/endpoints.rb', line 239

def mute(username)
  "#{@users_url}#{username}/mute?access_token=#{Settings.user_token}"
end

#muted(options) ⇒ Object



153
154
155
# File 'lib/ayadn/endpoints.rb', line 153

def muted(options)
  "#{@users_url}me/muted/?access_token=#{Settings.user_token}&count=#{options[:count]}&before_id=#{options[:before_id]}"
end

#photos(options) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/ayadn/endpoints.rb', line 75

def photos(options)
  @options_list = if options[:count] || options[:since_id]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:photos]})
  end
  "#{@posts_url}stream/explore/photos?access_token=#{Settings.user_token}#{@options_list}"
end

#posts(username, options) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/ayadn/endpoints.rb', line 102

def posts(username, options)
  @options_list = if options[:count]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:posts]})
  end
  if Settings.global[:force] == true
    "#{@users_url}#{username}/posts/?#{@options_list}"
  else
    "#{@users_url}#{username}/posts/?access_token=#{Settings.user_token}#{@options_list}"
  end
end

#repost(post_id) ⇒ Object



247
248
249
# File 'lib/ayadn/endpoints.rb', line 247

def repost(post_id)
  "#{@posts_url}#{post_id}/repost?access_token=#{Settings.user_token}"
end

#search(words, options) ⇒ Object



165
166
167
168
169
170
171
172
# File 'lib/ayadn/endpoints.rb', line 165

def search(words, options)
  @options_list = if options[:count]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:search]})
  end
  "#{@posts_url}search?text=#{words}&access_token=#{Settings.user_token}#{@options_list}"
end

#search_annotations(anno, options) ⇒ Object



183
184
185
186
187
188
189
190
# File 'lib/ayadn/endpoints.rb', line 183

def search_annotations anno, options
  @options_list = if options[:count]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:search]})
  end
  "#{@posts_url}search?annotation_types=#{anno}&access_token=#{Settings.user_token}#{@options_list}"
end

#search_channels(words, options) ⇒ Object



201
202
203
204
# File 'lib/ayadn/endpoints.rb', line 201

def search_channels words, options
    @options_list = API.build_query({count: Settings.options[:counts][:search]})
  "#{@channels_url}search?q=#{words}&order=popularity&access_token=#{Settings.user_token}#{@options_list}"
end

#search_messages(channel_id, words, options) ⇒ Object



192
193
194
195
196
197
198
199
# File 'lib/ayadn/endpoints.rb', line 192

def search_messages channel_id, words, options
  @options_list = if options[:count]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:search]})
  end
  "#{@channels_url}messages/search?query=#{words}&channel_ids=#{channel_id}&access_token=#{Settings.user_token}#{@options_list}"
end

#search_users(words, options) ⇒ Object



174
175
176
177
178
179
180
181
# File 'lib/ayadn/endpoints.rb', line 174

def search_users words, options
  @options_list = if options[:count]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:search]})
  end
  "#{@users_url}search?q=#{words}&access_token=#{Settings.user_token}#{@options_list}"
end

#single_post(post_id, options) ⇒ Object



214
215
216
# File 'lib/ayadn/endpoints.rb', line 214

def single_post(post_id, options)
  "#{@posts_url}#{post_id}?access_token=#{Settings.user_token}#{API.build_query(options)}"
end

#star(post_id) ⇒ Object



251
252
253
# File 'lib/ayadn/endpoints.rb', line 251

def star(post_id)
  "#{@posts_url}#{post_id}/star?access_token=#{Settings.user_token}"
end

#token_infoObject



23
24
25
# File 'lib/ayadn/endpoints.rb', line 23

def token_info
  "#{@token_url}?access_token=#{Settings.user_token}"
end


66
67
68
69
70
71
72
73
# File 'lib/ayadn/endpoints.rb', line 66

def trending(options)
  @options_list = if options[:count] || options[:since_id]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:trending]})
  end
  "#{@posts_url}stream/explore/trending?access_token=#{Settings.user_token}#{@options_list}"
end

#unified(options) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/ayadn/endpoints.rb', line 35

def unified(options)
  @options_list = if options[:count] || options[:since_id]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:unified]})
  end
  "#{@posts_url}stream/unified?access_token=#{Settings.user_token}#{@options_list}"
end

#update_markerObject



275
276
277
# File 'lib/ayadn/endpoints.rb', line 275

def update_marker
  "#{@posts_url}marker?access_token=#{Settings.user_token}"
end

#user(username) ⇒ Object

accepts a string



206
207
208
# File 'lib/ayadn/endpoints.rb', line 206

def user(username) # accepts a string
  "#{@users_url}#{username}?access_token=#{Settings.user_token}&include_user_annotations=1"
end

#users(usernames) ⇒ Object

accepts an array



210
211
212
# File 'lib/ayadn/endpoints.rb', line 210

def users(usernames) # accepts an array
  "#{@users_url}?ids=#{usernames.join(',')}?access_token=#{Settings.user_token}&include_user_annotations=1"
end

#whatstarred(username, options) ⇒ Object



115
116
117
118
119
120
121
122
# File 'lib/ayadn/endpoints.rb', line 115

def whatstarred(username, options)
  @options_list = if options[:count]
    API.build_query(options)
  else
    API.build_query({count: Settings.options[:counts][:default]})
  end
  "#{@users_url}#{username}/stars/?access_token=#{Settings.user_token}#{@options_list}"
end

#whoreposted(post_id) ⇒ Object



128
129
130
# File 'lib/ayadn/endpoints.rb', line 128

def whoreposted(post_id)
  "#{@posts_url}#{post_id}/reposters/?access_token=#{Settings.user_token}"
end

#whostarred(post_id) ⇒ Object



132
133
134
# File 'lib/ayadn/endpoints.rb', line 132

def whostarred(post_id)
  "#{@posts_url}#{post_id}/stars/?access_token=#{Settings.user_token}"
end