croudia4r 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +4 -0
  4. data/Gemfile +4 -0
  5. data/README.md +87 -0
  6. data/Rakefile +6 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +7 -0
  9. data/croudia4r.gemspec +25 -0
  10. data/lib/croudia/client.rb +85 -0
  11. data/lib/croudia/error.rb +5 -0
  12. data/lib/croudia/object/base.rb +30 -0
  13. data/lib/croudia/object/cursor.rb +9 -0
  14. data/lib/croudia/object/entities.rb +10 -0
  15. data/lib/croudia/object/identity.rb +9 -0
  16. data/lib/croudia/object/ids.rb +9 -0
  17. data/lib/croudia/object/list.rb +10 -0
  18. data/lib/croudia/object/location.rb +9 -0
  19. data/lib/croudia/object/media.rb +9 -0
  20. data/lib/croudia/object/relationship.rb +11 -0
  21. data/lib/croudia/object/relationship_collection.rb +9 -0
  22. data/lib/croudia/object/relationship_user.rb +9 -0
  23. data/lib/croudia/object/search_metadata.rb +10 -0
  24. data/lib/croudia/object/search_result.rb +12 -0
  25. data/lib/croudia/object/secret_mail.rb +16 -0
  26. data/lib/croudia/object/source.rb +9 -0
  27. data/lib/croudia/object/status.rb +21 -0
  28. data/lib/croudia/object/tokens.rb +9 -0
  29. data/lib/croudia/object/trend.rb +14 -0
  30. data/lib/croudia/object/trend_details.rb +9 -0
  31. data/lib/croudia/object/user.rb +15 -0
  32. data/lib/croudia/rest/account.rb +57 -0
  33. data/lib/croudia/rest/blocks.rb +56 -0
  34. data/lib/croudia/rest/favorites.rb +47 -0
  35. data/lib/croudia/rest/followers.rb +36 -0
  36. data/lib/croudia/rest/friend_ships.rb +60 -0
  37. data/lib/croudia/rest/friends.rb +36 -0
  38. data/lib/croudia/rest/mutes/users.rb +58 -0
  39. data/lib/croudia/rest/mutes.rb +9 -0
  40. data/lib/croudia/rest/oauth.rb +48 -0
  41. data/lib/croudia/rest/search.rb +33 -0
  42. data/lib/croudia/rest/secret_mails.rb +96 -0
  43. data/lib/croudia/rest/statuses.rb +170 -0
  44. data/lib/croudia/rest/trends.rb +19 -0
  45. data/lib/croudia/rest/users.rb +33 -0
  46. data/lib/croudia/version.rb +3 -0
  47. data/lib/croudia.rb +2 -0
  48. metadata +145 -0
@@ -0,0 +1,47 @@
1
+ require 'croudia/object/status'
2
+
3
+ module Croudia
4
+ module Rest
5
+ module Favorites
6
+
7
+ # **This method must throw Exception.**
8
+ # Returns the 20 most recent Whispers favorited by the authenticating or specified user.
9
+ #
10
+ # @see https://developer.croudia.com/docs/51_favorites
11
+ # @return [NotImplementedError]
12
+ # @param params [Hash] A customized options.
13
+ # @option params [Boolean] :trim_user When set to true, each whisper returned in a timeline will include a user object including only the status authors numerical ID.
14
+ def favorites(params = {})
15
+ raise NotImplementedError.new()
16
+ end
17
+
18
+ # Favorites the status specified in the ID parameter as the authenticating user.
19
+ # Returns the favorited status when successful.
20
+ #
21
+ # @see https://developer.croudia.com/docs/52_favorites_create
22
+ # @return [Croudia::Object::Status] Favorited status.
23
+ # @param status [Croudia::Object::Status] The favorite whisper.
24
+ # @param params [Hash] A customized options.
25
+ # @option params [Boolean] :trim_user When set to true, each whisper returned in a timeline will include a user object including only the status authors numerical ID.
26
+ # @option params [Boolean] :include_entities The entities node will be omitted when set to false.
27
+ def favorite(status, params = {})
28
+ response = post("2/favorites/create/#{status.id}.json", params)
29
+ Croudia::Object::Status.new(response)
30
+ end
31
+
32
+ # Un-favorites the status specified in the ID parameter as the authenticating user.
33
+ # Returns the un-favorited status when successful.
34
+ #
35
+ # @see https://developer.croudia.com/docs/53_favorites_destroy
36
+ # @return [Croudia::Object::Status] Un-favorited status.
37
+ # @param status [Croudia::Object::Status] The un-favorite whisper.
38
+ # @param params [Hash] A customized options.
39
+ # @option params [Boolean] :trim_user When set to true, each whisper returned in a timeline will include a user object including only the status authors numerical ID.
40
+ # @option params [Boolean] :include_entities The entities node will be omitted when set to false.
41
+ def unfavorite(status, params = {})
42
+ response = post("2/favorites/destory/#{status.id}.json", params)
43
+ Croudia::Object::Status.new(response)
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,36 @@
1
+ require 'croudia/object/ids'
2
+ require 'croudia/object/list'
3
+
4
+ module Croudia
5
+ module Rest
6
+ module Followers
7
+
8
+ # Returns a collection of user ids that the authenticating user's followers.
9
+ #
10
+ # @see https://developer.croudia.com/docs/49_followers_ids
11
+ # @return [Croudia::Object::IDs] A collection of user ids that authenticating user's followers.
12
+ # @param params [Hash] A customized options.
13
+ # @option params [String] :screen_name The screen name of the potentially followers user.
14
+ # @option params [Integer] :user_id The ID of the potentially followers user.
15
+ # @option params [Integer] :cursor The page cursor of collection.
16
+ def follower_ids(params = {})
17
+ response = get('followers/ids.json', params)
18
+ Croudia::Object::IDs.new(response)
19
+ end
20
+
21
+ # Returns a collection of user objects the authenticating user's followers.
22
+ #
23
+ # @see https://developer.croudia.com/docs/43_followers_list
24
+ # @return [Croudia::Object::List] A collection of user objects that authenticating user's followers.
25
+ # @param params [Hash] A customized options.
26
+ # @option params [String] :screen_name The screen name of the potentially followers user.
27
+ # @option params [Integer] :user_id The ID of the potentially followers user.
28
+ # @option params [Integer] :cursor The page cursor of collection.
29
+ # @option params [Boolean] :trim_user When set to truem each whisper returned in a timeline will include a user object including only the status authors numerical ID.
30
+ def followers(params = {})
31
+ response = get('followers/list.json', params)
32
+ Croudia::Object::List.new(response)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,60 @@
1
+ require 'croudia/object/relationship'
2
+ require 'croudia/object/relationship_collection'
3
+ require 'croudia/object/user'
4
+
5
+ module Croudia
6
+ module Rest
7
+ module FriendShips
8
+
9
+ # Allows the authenticating users to follow the user specified in the ID parameter.
10
+ #
11
+ # @see https://developer.croudia.com/docs/41_friendships_create
12
+ # @return [Croudia::Object::User] The befriended user in the requested format when successful.
13
+ # @param params [Hash] A customized options.
14
+ # @option params [String] :screen_name The screen name of the user for whom to befriend.
15
+ # @option params [Integer] :user_id The ID of the user for whom to befriend.
16
+ def follow(params = {})
17
+ response = post('friendships/create.json', params)
18
+ Croudia::Object::User.new(response)
19
+ end
20
+
21
+ # Allows the authenticating user to unfollow the user specified in the ID parameter.
22
+ #
23
+ # @see https://developer.croudia.com/docs/42_friendships_destroy
24
+ # @return [Croudia::Object::User] The unfollowed user in the requested format when successful.
25
+ # @param params [Hash] A customized options.
26
+ # @option params [String] :screen_name The screen name of the user for whom to unfollow.
27
+ # @option params [Integer] :user_id The ID of the user for whom to unfollow.
28
+ def unfollow(params = {})
29
+ response = post('friendships/destroy.json', params)
30
+ Croudia::Object::User.new(response)
31
+ end
32
+
33
+ # Returns detailed information about the relationship between two arbitrary users.
34
+ #
35
+ # @see https://developer.croudia.com/docs/44_friendships_show
36
+ # @return [Croudia::Object::Relationship] The relationship between two arbitrary users.
37
+ # @param params [Hash] A customized options.
38
+ # @option params [Integer] :source_id The user_id of the subject user.
39
+ # @option params [String] :source_screen_name The screen_name of the subject user.
40
+ # @option params [Integer] :target_id The user_id of the target user.
41
+ # @option params [String] :target_screen_name The screen_name of the target user.
42
+ def relationship(params = {})
43
+ response = get('friendships/show.json', params)
44
+ Croudia::Object::Relationship.new(response)
45
+ end
46
+
47
+ # Returns the relationships of the authenticating user to the comma-separated list of up to 100 screen_names or user_ids provided.
48
+ #
49
+ # @see https://developer.croudia.com/docs/47_friendships_lookup
50
+ # @return [Croudia::Object::RelationshipCollection]
51
+ # @param params [Hash] A customized options.
52
+ # @option params [Integer] :user_id The comma-separated list of user_ids.
53
+ # @option params [String] :screen_name The comma-separated list of screen_names.
54
+ def relationships(params = {})
55
+ response = get('friendships/lookup.json', params)
56
+ Croudia::Object::RelationshipCollection.new(response)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,36 @@
1
+ require 'croudia/object/ids'
2
+ require 'croudia/object/list'
3
+
4
+ module Croudia
5
+ module Rest
6
+ module Friends
7
+
8
+ # Returns a collection of user ids that the authenticating user's friends.
9
+ #
10
+ # @see https://developer.croudia.com/docs/49_friends_ids
11
+ # @return [Croudia::Object::IDs] A collection of user ids that authenticating user's friends.
12
+ # @param params [Hash] A customized options.
13
+ # @option params [String] :screen_name The screen name of the potentially friends user.
14
+ # @option params [Integer] :user_id The ID of the potentially friends user.
15
+ # @option params [Integer] :cursor The page cursor of collection.
16
+ def friend_ids(params = {})
17
+ response = get('friends/ids.json', params)
18
+ Croudia::Object::IDs.new(response)
19
+ end
20
+
21
+ # Returns a collection of user objects the authenticating user's friends.
22
+ #
23
+ # @see https://developer.croudia.com/docs/43_friends_list
24
+ # @return [Croudia::Object::List] A collection of user objects that authenticating user's friends.
25
+ # @param params [Hash] A customized options.
26
+ # @option params [String] :screen_name The screen name of the potentially friends user.
27
+ # @option params [Integer] :user_id The ID of the potentially friends user.
28
+ # @option params [Integer] :cursor The page cursor of collection.
29
+ # @option params [Boolean] :trim_user When set to truem each whisper returned in a timeline will include a user object including only the status authors numerical ID.
30
+ def friends(params = {})
31
+ response = get('friends/list.json', params)
32
+ Croudia::Object::List.new(response)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,58 @@
1
+ require 'croudia/object/user'
2
+ require 'croudia/object/ids'
3
+ require 'croudia/object/list'
4
+
5
+ module Croudia
6
+ module Rest
7
+ module Mutes
8
+ module Users
9
+
10
+ # Mutes the user specified in the ID parameter for the authenticating user.
11
+ #
12
+ # @see https://developer.croudia.com/docs/71_mutes_users_create
13
+ # @return [Croudia::Object::User] Muted user.
14
+ # @param params [Hash] A customized options.
15
+ # @option params [String] :screen_name The screen name of the potentially muted user.
16
+ # @option params [Integer] :user_id The ID of the potentially muted user.
17
+ def mute(params = {})
18
+ response = post('mutes/users/create.json', params)
19
+ Croudia::Object::User.new(response)
20
+ end
21
+
22
+ # Un-mutes the user specified in the ID parameter for the authenticating user.
23
+ #
24
+ # @see https://developer.croudia.com/docs/72_mutes_users_destroy
25
+ # @return [Croudia::Object::User] Un-muted user.
26
+ # @param params [Hash] A customized options.
27
+ # @option params [String] :screen_name The screen name of the potentially unmuted user.
28
+ # @option params [Integer] :user_id The ID of the potentially unmuted user.
29
+ def umnute(params = {})
30
+ response = post('mutes/users/destroy.json', params)
31
+ Croudia::Object::User.new(response)
32
+ end
33
+
34
+ # Returns a collection of users the authenticating user has muted.
35
+ #
36
+ # @see https://developer.croudia.com/docs/74_mutes_users_list
37
+ # @param params [Hash] A customized options.
38
+ # @option params [Integer] :cursor The page cursor.
39
+ # @option params [Boolean] :trim_user When set to true, objects returned will include a user object including only the status authors numerical ID.
40
+ def mutes(params = {})
41
+ response = get('mutes/users/list.json', params)
42
+ Croudia::Object::List.new(response)
43
+ end
44
+
45
+ # Returns an array of numeric user ids the authenticating user has muted.
46
+ #
47
+ # @see https://developer.croudia.com/docs/75_mutes_users_ids
48
+ # @return [Croudia::Object::IDs] Numeric user ids the authenticating user has muted.
49
+ # @param params [Hash] A customized options.
50
+ # @option params [Integer] :cursor The page cursor.
51
+ def mute_ids(params = {})
52
+ response = get('mutes/users/ids.json', params)
53
+ Croudia::Object::IDs.new(response)
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,9 @@
1
+ require 'croudia/rest/mutes/users'
2
+
3
+ module Croudia
4
+ module Rest
5
+ module Mutes
6
+ include Croudia::Rest::Mutes::Users
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,48 @@
1
+ require 'croudia/object/tokens'
2
+
3
+ module Croudia
4
+ module Rest
5
+ module OAuth
6
+
7
+ # Returns an authorization url.
8
+ #
9
+ # @return [String] Authorization url.
10
+ # @param params [Hash] A customized options.
11
+ # @option params [String] :state OAuth 2 Authorization State Code.
12
+ def authorize_url(params = {})
13
+ unless (params[:state].nil?)
14
+ "https://api.croudia.com/oauth/authorize?response_type=code&client_id=#{@client_id}&state=#{params[:state]}"
15
+ else
16
+ "https://api.croudia.com/oauth/authorize?response_type=code&client_id=#{@client_id}"
17
+ end
18
+ end
19
+
20
+ # Allows a registered application to obtain an OAuth 2 Bearer Token.
21
+ #
22
+ # @see https://developer.croudia.com/docs/oauth
23
+ # @return [Croudia::Object::Tokens] Token pair.
24
+ # @param params [Hash] A customized options.
25
+ # @option params [String] :code Authorization code of application.
26
+ def token(params = {})
27
+ default_params = {grant_type: 'authorization_code', client_id: @client_id, client_secret: @client_secret}
28
+ params.merge!(default_params)
29
+ response = post('oauth/token', params)
30
+ puts response
31
+ Croudia::Object::Tokens.new(response)
32
+ end
33
+
34
+ # Refresh an OAuth 2 Bearer Token.
35
+ #
36
+ # @see https://developer.croudia.com/docs/oauth
37
+ # @return [Croudia::Object::Tokens] Token pair.
38
+ # @param params [Hash] A customized options.
39
+ # @option params [String] :refresh_token OAuth 2 refresh token.
40
+ def refresh(params = {})
41
+ default_params = {grant_type: 'refresh_token', client_id: @client_id, client_secret: @client_secret }
42
+ params.merge!(default_params)
43
+ response = post('oauth/token', params)
44
+ Croudia::Object::Tokens.new(response)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,33 @@
1
+ require 'croudia/object/search_result'
2
+ require 'croudia/object/user'
3
+
4
+ module Croudia
5
+ module Rest
6
+ module Search
7
+
8
+ def search_statuses(params = {})
9
+ response = get('search/voices.json', params)
10
+ Croudia::Object::SearchResult.new(response)
11
+ end
12
+
13
+ def search_users(params = {})
14
+ response = get('users/search.json', params)
15
+ response.map do |user|
16
+ Croudia::Object::User.new(user)
17
+ end
18
+ end
19
+
20
+ def search_users_by_profile(params = {})
21
+ response = get('profile/search.json', params)
22
+ response.map do |user|
23
+ Croudia::Object::User.new(user)
24
+ end
25
+ end
26
+
27
+ def search_favorites(params = {})
28
+ response = get('search/favorites.json', params)
29
+ Croudia::Object::SearchResult.new(response)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,96 @@
1
+ require 'croudia/object/secret_mail'
2
+
3
+ module Croudia
4
+ module Rest
5
+ module SecretMails
6
+
7
+ # Returns the 20 most recent direct messages sent to the authenticating user.
8
+ #
9
+ # @see https://developer.croudia.com/docs/21_secret_mails
10
+ # @return [Array<Croudia::Object::SecretMail>] Secret mails that authenticating user is received.
11
+ # @param params [Hash] A customized options.
12
+ # @option params [Boolean] :trim_user When set to true, each message returned in a timeline will include a user object including only the status authors numerical ID.
13
+ # @option params [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
14
+ # @option params [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
15
+ # @option params [Integer] :count Specifies the number of statuses to retrieve.
16
+ def received(params = {})
17
+ response = get('secret_mails.json', params)
18
+ response.map do |sm|
19
+ Croudia::Object::SecretMail.new(sm)
20
+ end
21
+ end
22
+
23
+ # Returns the 20 most recent direct messages sent by the authenticating user.
24
+ #
25
+ # @see https://developer.croudia.com/docs/22_secret_mails_sent
26
+ # @return [Array<Croudia::Object::SecretMail>] Secret mails that authenticating user is sent.
27
+ # @param params [Hash] A customized options.
28
+ # @option params [Boolean] :trim_user When set to true, each message returned in a timeline will include a user object including only the status authors numerical ID.
29
+ # @option params [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
30
+ # @option params [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
31
+ # @option params [Integer] :count Specifies the number of statuses to retrieve.
32
+ def sent(params = {})
33
+ response = get('secret_mails/sent.json', params)
34
+ response.map do |sm|
35
+ Croudia::Object::SecretMail.new(sm)
36
+ end
37
+ end
38
+
39
+ # Sends a new message to the specified user from the authenticating user.
40
+ #
41
+ # @see https://developer.croudia.com/docs/23_secret_mails_new
42
+ # @return [Croudia::Object::SecretMail] Sent message.
43
+ # @param params [Hash] A customized options.
44
+ # @option params [String] :text The text of your status update, typically up to 372 characters.
45
+ # @option params [String] :screen_name The screen name of the user for whom to send message.
46
+ # @option params [Integer] :user_id The ID of the user for whom to send message.
47
+ def new_message(params = {})
48
+ response = post('secret_mails/new.json', params)
49
+ Croudia::Object::SecretMail.new(response)
50
+ end
51
+
52
+ # Sends a new message with image to the specified user from the authenticating user.
53
+ #
54
+ # @see https://developer.croudia.com/docs/26_secret_mails_new_with_media
55
+ # @return [Croudia::Object::SecretMail] Sent message.
56
+ # @param params [Hash] A customized options.
57
+ # @option params [String] :text The text of your status update, typically up to 372 characters.
58
+ # @option params [File] :media Attachment image as PNG, JPEG or GIF format.
59
+ # @option params [String] :screen_name The screen name of the user for whom to send message.
60
+ # @option params [Integer] :user_id The ID of the user for whom to send message.
61
+ def new_message_with_media(params = {})
62
+ response = post('secret_mails/new_with_media.json', params)
63
+ Croudia::Object::SecretMail.new(response)
64
+ end
65
+
66
+ # Deletes the authenticating user's sent message.
67
+ #
68
+ # @see https://developer.croudia.com/docs/24_secret_mails_destroy
69
+ # @return [Croudia::Object::SecretMail] Deleted message.
70
+ # @param status [Croudia::Object::SecretMail] Delete status.
71
+ def delete_message(status)
72
+ response = post("secret_mails/destroy/#{status.id}.json")
73
+ Croudia::Object::SecretMail.new(response)
74
+ end
75
+
76
+ # Returns a single message, specified by the id parameter.
77
+ #
78
+ # @see https://developer.croudia.com/docs/25_secret_mails_show
79
+ # @return [Croudia::Object::SecretMail] Message specified by id.
80
+ # @param status [Croudia::Object::SecretMail] Message.
81
+ def message(status)
82
+ response = get("secret_mails/show/#{status.id}.json")
83
+ Croudia::Object::SecretMail.new(response)
84
+ end
85
+
86
+ # Returns the URI of the image that attached to message.
87
+ #
88
+ # @see https://developer.croudia.com/docs/27_secret_mails_get_secret_photo
89
+ # @return [String] URL of attaching message.
90
+ # @param status [Croudia::Object::SecretMail] Status.
91
+ def message_photo(status)
92
+ "https://api.croudia.com/secret_mails/get_secret_photo/#{status.id}.json"
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,170 @@
1
+ require 'croudia/object/status'
2
+
3
+ module Croudia
4
+ module Rest
5
+ module Statuses
6
+
7
+ # Returns a collection of the most recent Whispers, spreads and comments posted by the authenticating user and the users they non-protected.
8
+ #
9
+ # @see https://developer.croudia.com/docs/01_statuses_public_timeline
10
+ # @return [Array<Croudia::Object::Status>] Collection of the most recent statuses.
11
+ # @param params [Hash] A customized options.
12
+ # @option params [Boolean] :trim_user When set to true, each whisper returned in a timeline will include a user object including only the status authors numerical ID.
13
+ # @option params [Boolean] :include_entities The entities node will be omitted when set to false.
14
+ # @option params [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
15
+ # @option params [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
16
+ # @option params [Integer] :count Specifies the number of statuses to retrieve.
17
+ def public_timeline(params = {})
18
+ response = get('2/statuses/public_timeline.json', params)
19
+ response.map{ |status| Croudia::Object::Status.new(status) }
20
+ end
21
+
22
+ # Returns a collection of the most recent Whispers, spreads and comments posted by the authenticating user and the users they following.
23
+ #
24
+ # @see https://developer.croudia.com/docs/02_statuses_home_timeline
25
+ # @return [Array<Croudia::Object::Status>] Collection of the most recent statuses.
26
+ # @param params [Hash] A customized options.
27
+ # @option params [Boolean] :trim_user When set to true, each whisper returned in a timeline will include a user object including only the status authors numerical ID.
28
+ # @option params [Boolean] :include_entities The entities node will be omitted when set to false.
29
+ # @option params [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
30
+ # @option params [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
31
+ # @option params [Integer] :count Specifies the number of statuses to retrieve.
32
+ def home_timeline(params = {})
33
+ response = get('2/statuses/home_timeline.json', params)
34
+ response.map{ |status| Croudia::Object::Status.new(status) }
35
+ end
36
+
37
+ # Returns a collection of the most recent Whispers, spreads and comments posted by specified user.
38
+ #
39
+ # @see https://developer.croudia.com/docs/03_statuses_user_timeline
40
+ # @return [Array<Croudia::Object::Status>] Collection of the most recent statuses.
41
+ # @param params [Hash] A customized options.
42
+ # @option params [String] :screen_name The screen name of the user for whom to return results for.
43
+ # @option params [Integer] :user_id The ID of the user for whom to return results for.
44
+ # @option params [Boolean] :trim_user When set to true, each whisper returned in a timeline will include a user object including only the status authors numerical ID.
45
+ # @option params [Boolean] :include_entities The entities node will be omitted when set to false.
46
+ # @option params [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
47
+ # @option params [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
48
+ # @option params [Integer] :count Specifies the number of statuses to retrieve.
49
+ def user_timeline(params = {})
50
+ response = get('2/statuses/user_timeline.json', params)
51
+ response.map{ |status| Croudia::Object::Status.new(status) }
52
+ end
53
+
54
+ # Returns the 20 most recent mentions (Whispers containing a users’s @screen_name) for the authenticating user.
55
+ #
56
+ # @see https://developer.croudia.com/docs/04_statuses_mentions
57
+ # @return [Array<Croudia::Object::Status>] Collection of the most recent statuses.
58
+ # @param params [Hash] A customized options.
59
+ # @option params [Boolean] :trim_user When set to true, each whisper returned in a timeline will include a user object including only the status authors numerical ID.
60
+ # @option params [Boolean] :include_entities The entities node will be omitted when set to false.
61
+ # @option params [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
62
+ # @option params [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
63
+ # @option params [Integer] :count Specifies the number of statuses to retrieve.
64
+ def mentions_timeline(params = {})
65
+ response = get('2/statuses/mentions.json', params)
66
+ response.map{ |status| Croudia::Object::Status.new(status) }
67
+ end
68
+
69
+ # Updates the authenticating user’s current status.
70
+ #
71
+ # @see https://developer.croudia.com/docs/11_statuses_update
72
+ # @return [Croudia::Object::Status] Updated status.
73
+ # @param params [Hash] A customized options.
74
+ # @option params [String] :status The text of your status update, typically up to 372 characters.
75
+ # @option params [Integer] :in_reply_to_status_id The ID of an existing status that the update is in reply to.
76
+ # @option params [Integer] :timer Whispers timer's seconds.
77
+ # @option params [Boolean] :trim_user When set to true, the whisper returned will include a user object including only the status authors numerical ID.
78
+ # @option params [Boolean] :include_entities The entities node will be omitted when set to false.
79
+ def update_status(params = {})
80
+ response = post('2/statuses/update.json', params)
81
+ Croudia::Object::Status.new(response)
82
+ end
83
+
84
+ # Updates the authenticating user's current status with media as photos.
85
+ #
86
+ # @see https://developer.croudia.com/docs/14_statuses_update_with_media
87
+ # @return [Croudia::Object::Status] Updated status.
88
+ # @param params [Hash] A customized options.
89
+ # @option params [String] :status The text of your status update, typically up to 372 characters.
90
+ # @option params [File] :media Attachment image that PNG, JPEG or GIF format.
91
+ # @option params [Integer] :in_reply_to_status_id The ID of an existing status that the update is in reply to.
92
+ # @option params [Integer] :timer Whispers timer's seconds.
93
+ # @option params [Boolean] :trim_user When set to true, the whisper returned will include a user object including only the status authors numerical ID.
94
+ # @option params [Boolean] :include_entities The entities node will be omitted when set to false.
95
+ def update_status_with_media(params = {})
96
+ response = post('2/statuses/update_with_media.json', params)
97
+ Croudia::Object::Status.new(response)
98
+ end
99
+
100
+ # Deletes the authenticating user's status.
101
+ #
102
+ # @see https://developer.croudia.com/docs/12_statuses_destroy
103
+ # @return [Croudia::Object::Status] Deleted status.
104
+ # @param status [Croudia::Object::Status] Delete status.
105
+ # @param params [Hash] A customized options.
106
+ # @option params [Boolean] :trim_user When set to true, whisper returned will include a user object including only the status authors numerical ID.
107
+ # @option params [Boolean] :include_entities The entities node will be omitted when set to false.
108
+ def delete_status(status, params = {})
109
+ response = post("2/statuses/destory/#{status.id}.json", params)
110
+ Croudia::Object::Status.new(response)
111
+ end
112
+ alias_method :delete_spread, :delete_status
113
+
114
+ # Returns a single Whisper, specified by the id parameter.
115
+ #
116
+ # @see https://developer.croudia.com/docs/13_statuses_show
117
+ # @return [Croudia::Object::Status] Status specified by id.
118
+ # @param status [Croudia::Object::Status] Status.
119
+ # @param params [Hash] A customized options.
120
+ # @option params [Boolean] :trim_user When set to true, whisper returned will include a user object including only the status authors numerical ID.
121
+ # @option params [Boolean] :include_entities The entities node will be omitted when set to false.
122
+ def status(status, params = {})
123
+ response = get("2/statuses/show/#{status.id}.json", params)
124
+ Croudia::Object::Status.new(response)
125
+ end
126
+
127
+ # Shares the status by authenticating user.
128
+ #
129
+ # @see https://developer.croudia.com/docs/61_statuses_spread
130
+ # @return [Croudia::Object::Status] Status shread by id.
131
+ # @param status [Croudia::Object::Status] Status.
132
+ # @param params [Hash] A customized options.
133
+ # @option params [Boolean] :trim_user When set to true, whisper returned will include a user object including only the status authors numerical ID.
134
+ # @option params [Boolean] :include_entities The entities node will be omitted when set to false.
135
+ def spread(status, params = {})
136
+ response = post("2/statuses/spread/#{status.id}.json", params)
137
+ Croudia::Object::Status.new(response)
138
+ end
139
+
140
+ #
141
+ #
142
+ # @see https://developer.croudia.com/docs/112_statuses_comment
143
+ # @return [Croudia::Object::Status] Commented status.
144
+ # @param params [Hash] A customized options.
145
+ # @option params [Integer] :id Comment status id.
146
+ # @option params [String] :status Comment body.
147
+ # @option params [Boolean] :trim_user When set to true, whisper returned will include a user object including only the status authors numerical ID.
148
+ # @option params [Boolean] :include_entities The entities node will be omitted when set to false.
149
+ def comment(params = {})
150
+ response = post('2/statuses/comment.json', params)
151
+ Croudia::Object::Status.new(response)
152
+ end
153
+
154
+ #
155
+ #
156
+ # @see https://developer.croudia.com/docs/113_statuses_comment_with_media
157
+ # @return [Croudia::Object::Status] Commented status.
158
+ # @param params [Hash] A customized options.
159
+ # @option params [Integer] :id Comment status id.
160
+ # @option params [String] :status Comment body.
161
+ # @option params [File] :media Attachment media.
162
+ # @option params [Boolean] :trim_user When set to true, whisper returned will include a user object including only the status authors numerical ID.
163
+ # @option params [Boolean] :include_entities The entities node will be omitted when set to false.
164
+ def comment_with_media(params = {})
165
+ response = post('2/statuses/comment_with_media.json', params)
166
+ Croudia::Object::Status.new(response)
167
+ end
168
+ end
169
+ end
170
+ end
@@ -0,0 +1,19 @@
1
+ require 'croudia/object/trend'
2
+
3
+ module Croudia
4
+ module Rest
5
+ module Trends
6
+
7
+ # Returns the top 10 trending topics for a specific WOEID.
8
+ #
9
+ # @see https://developer.croudia.com/docs/100_trends_place
10
+ # @return [Croudia::Object::Trend] Trends
11
+ # @param params [Hash] A customized options.
12
+ # @option params [Integer] :woeid Please set 1.
13
+ def place(params = {})
14
+ response = get('trends/place.json', params)
15
+ Croudia::Object::Trend.new(response)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,33 @@
1
+ require 'croudia/object/user'
2
+
3
+ module Croudia
4
+ module Rest
5
+ module Users
6
+
7
+ # Returns a variety of information about the user.
8
+ #
9
+ # @see https://developer.croudia.com/docs/31_users_show
10
+ # @return [Croudia::Object::User] Variety of information about the user.
11
+ # @param params [Hash] A customized options.
12
+ # @option params [String] :screen_name The screen name of the user for whom to return results for.
13
+ # @option params [Integer] :user_id The ID of the user for whom to return results for.
14
+ def user(params = {})
15
+ response = get('users/show.json', params)
16
+ Croudia::Object::User.new(response)
17
+ end
18
+
19
+
20
+ # Returns a information about the up to 100 users.
21
+ #
22
+ # @see https://developer.croudia.com/docs/32_users_lookup
23
+ # @return [Array<Croudia::Object::User>] Information about the users.
24
+ # @param params [Hash] A customized options.
25
+ # @option params [String] :screen_name The camma-separated screen name of the user for whom to return results for.
26
+ # @option params [Integer] :user_id The camma-separated IDs of the user for whom to return results for.
27
+ def users(params = {})
28
+ response = get('users/lookup.json', params)
29
+ response.map {|user| Croudia::Object::User.new(user) }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module Croudia
2
+ VERSION = "0.1.1"
3
+ end
data/lib/croudia.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "croudia/version"
2
+ require "croudia/client"