Class: SocialMediaMonitoring::Client
- Inherits:
-
Object
- Object
- SocialMediaMonitoring::Client
- Includes:
- HTTParty
- Defined in:
- lib/social_media_monitoring/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #categories(country) ⇒ Object
- #competitors(cat_id, geo) ⇒ Object
- #create_keyword(keyword) ⇒ Object
-
#initialize(api_key = nil) ⇒ Client
constructor
curl -G -d -is “&api_key=ed08eba2bd5ef47bab6cb1944686fed2&country=de&cat_id=135&geo=53.66,10.1154” api.apphera.com/1/organizations Get a free api_key @ developer.apphera.com.
- #key_error(mes) ⇒ Object
- #keywords ⇒ Object
- #reviews(organization_id, review_id = 0) ⇒ Object
- #sentiment(body, lang) ⇒ Object
- #show_keyword(id) ⇒ Object
Constructor Details
#initialize(api_key = nil) ⇒ Client
curl -G -d -is “&api_key=ed08eba2bd5ef47bab6cb1944686fed2&country=de&cat_id=135&geo=53.66,10.1154” api.apphera.com/1/organizations Get a free api_key @ developer.apphera.com
10 11 12 13 14 15 |
# File 'lib/social_media_monitoring/client.rb', line 10 def initialize(api_key=nil) @api_key = api_key @api_key ||= SocialMediaMonitoring.api_key @api_path = '' end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/social_media_monitoring/client.rb', line 7 def api_key @api_key end |
Instance Method Details
#categories(country) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/social_media_monitoring/client.rb', line 16 def categories(country) begin results = Mash.new(self.class.get('/categories', :query => {:country => country}.merge(self.))) rescue => e key_error e end end |
#competitors(cat_id, geo) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/social_media_monitoring/client.rb', line 60 def competitors(cat_id, geo) = {:query => {:cat_id => cat_id, :geo => geo}.merge(self.)} begin results = Mash.new(self.class.get("/organizations", )) rescue => e key_error e end end |
#create_keyword(keyword) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/social_media_monitoring/client.rb', line 33 def create_keyword(keyword) = {:body => {:keyword => keyword}, :query => self.} begin results = Mash.new(self.class.post('/keywords/create', )) rescue => e key_error e end end |
#key_error(mes) ⇒ Object
78 79 80 |
# File 'lib/social_media_monitoring/client.rb', line 78 def key_error(mes) "Invalid key or no Internet connection. Please obtain a free API key at https://developer.apphera.com or try one of the public keys from https://github.com/nikoma/social_media_monitoring, the complete error message is: #{mes}" end |
#keywords ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/social_media_monitoring/client.rb', line 25 def keywords begin results = Mash.new(self.class.get('/keywords', :query => self.)) rescue => e key_error e end end |
#reviews(organization_id, review_id = 0) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/social_media_monitoring/client.rb', line 70 def reviews(organization_id, review_id=0) = {:query => {:organization_id => organization_id, :review_id => review_id}.merge(self.)} begin results = Mash.new(self.class.get("/reviews", )) rescue => e key_error e end end |
#sentiment(body, lang) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/social_media_monitoring/client.rb', line 51 def sentiment(body, lang) = {:body => {:body => body, :lang => lang}, :query => self.} begin results = Mash.new(self.class.post('/sentiments', )) rescue => e key_error e end end |
#show_keyword(id) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/social_media_monitoring/client.rb', line 42 def show_keyword(id) = {:query => self.} begin results = Mash.new(self.class.get("/keywords/#{id}", )) rescue => e key_error e end end |