Class: Ayadn::Endpoints

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

Constant Summary collapse

CALLBACK_URL =
"http://aya.io/ayadn/auth.html"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEndpoints

uncomment and insert your own URL CALLBACK_URL = “”



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ayadn/endpoints.rb', line 13

def initialize
  @ayadn_callback_url = CALLBACK_URL
  api_file = Dir.home + "/ayadn/.api.yml"
  @base_url = if File.exist?(api_file)
    YAML.load(File.read(api_file))[:root] + "/"
  else
    "https://api.app.net/"
  end
  @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



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

def authorize_url
  "https://account.app.net/oauth/authenticate?client_id=#{Settings::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



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

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

#block(username) ⇒ Object



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

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

#blocked(options) ⇒ Object



168
169
170
# File 'lib/ayadn/endpoints.rb', line 168

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



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

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



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

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

#checkins(options) ⇒ Object



73
74
75
76
77
78
# File 'lib/ayadn/endpoints.rb', line 73

def checkins(options)
  make_options_list(options) do
    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



105
106
107
108
109
110
# File 'lib/ayadn/endpoints.rb', line 105

def conversations(options)
  make_options_list(options) do
    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



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

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

#coverObject



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

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

#delete_message(channel_id, message_id) ⇒ Object



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

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



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

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

#file(file_id) ⇒ Object



38
39
40
# File 'lib/ayadn/endpoints.rb', line 38

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

#filesObject



42
43
44
# File 'lib/ayadn/endpoints.rb', line 42

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

#files_list(options) ⇒ Object



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

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

#follow(username) ⇒ Object



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

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

#followers(username, options) ⇒ Object



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

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



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

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



80
81
82
83
84
85
86
87
88
89
# File 'lib/ayadn/endpoints.rb', line 80

def global(options)
  make_options_list(options) do
    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



172
173
174
# File 'lib/ayadn/endpoints.rb', line 172

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

#interactionsObject



137
138
139
# File 'lib/ayadn/endpoints.rb', line 137

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

#mentions(username, options) ⇒ Object



112
113
114
115
116
117
# File 'lib/ayadn/endpoints.rb', line 112

def mentions(username, options)
  make_options_list_simple(options) do
    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



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

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



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

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

#muted(options) ⇒ Object



164
165
166
# File 'lib/ayadn/endpoints.rb', line 164

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

#photos(options) ⇒ Object



98
99
100
101
102
103
# File 'lib/ayadn/endpoints.rb', line 98

def photos(options)
  make_options_list(options) do
    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



119
120
121
122
123
124
125
126
127
128
# File 'lib/ayadn/endpoints.rb', line 119

def posts(username, options)
  make_options_list_simple(options) do
    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



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

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

#search(words, options) ⇒ Object



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

def search(words, options)
  make_options_list_simple(options) do
    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



190
191
192
193
194
195
# File 'lib/ayadn/endpoints.rb', line 190

def search_annotations anno, options
  make_options_list_simple(options) do
    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



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

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



197
198
199
200
201
202
# File 'lib/ayadn/endpoints.rb', line 197

def search_messages channel_id, words, options
  make_options_list_simple(options) do
    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



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

def search_users words, options
  make_options_list_simple(options) do
    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



217
218
219
# File 'lib/ayadn/endpoints.rb', line 217

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

#star(post_id) ⇒ Object



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

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

#token_infoObject



34
35
36
# File 'lib/ayadn/endpoints.rb', line 34

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


91
92
93
94
95
96
# File 'lib/ayadn/endpoints.rb', line 91

def trending(options)
  make_options_list(options) do
    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



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

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

#update_markerObject



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

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

#user(username) ⇒ Object

accepts a string



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

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



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

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



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

def whatstarred(username, options)
  make_options_list_simple(options) do
    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



141
142
143
# File 'lib/ayadn/endpoints.rb', line 141

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

#whostarred(post_id) ⇒ Object



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

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