QuickBlox Ruby Gem

Ask tech team
From QuickBlox Developers (API docs, code samples, SDK)
(Redirected from QuckBlox Ruby Gem)
Jump to: navigation, search

Contents

Installation

QuickBlox Ruby Gem is a library for integrating ruby application with QuickBlox API.

There are 2 ways how to install a gem - to fork it from GitHub or to install it as a native gem:

gem install quickblox

Configuration

First - rename or create config.yml file in your project root wit following content:

quickblox:
   application_id: 1
   auth_key: LNFYqQ9XX43dVPJ
   auth_secret: WyXEMXXXXWAe-q
   server: api.quickblox.com
   user_owner_id: 3
   user_login: user10
   user_password: pass
   device_platform: android
   device_udid: 1231asdsdf23123ss3

Rquiered virables are 

  • application_id
  • auth_key
  • auth_secret
  • server
  • user_owner_id

Optional variables are

  • user_login
  • user_password
  • user_device
  • device_udid

Optional variables are used for debugging or testing the application.

User and device variables

User and device credentials are stored in the global variables that could be set and changet across the project:

  • @user_login = "mylogin"
  • @user_password = "my_supersecure_password"
  • @device_platform = "ios"
  • @device_udid = "b234kjr4bkjKNKJNJKNJkfjej333334"

Depending on this variables you will be able to recieve tokens that belong to different entities.

Error handling

Almast all methods contain HTTP error handling with a hash:

  • response_code - HTTP code of the response
  • response_header - Response description
  • response_body - Response body

Examples:

1.9.2p318 :002 > m.delete_event(670)
=> {:response_code=>"404", :response_header=>#<Net::HTTPNotFound 404 Not Found readbody=true>, :response_body=>nil}
 
1.9.2p318 :003 > m.create_event({:event=>{:notification_type=>"pull",:date=>1334226795,:end_date=>1334227795,:user=>{:ids=>"254"}, :environment=>"development"}},{:body=>"Messagee"})
=> {:response_code=>"422", :response_header=>#<Net::HTTPClientError 422 Unprocessable Entity readbody=true>, :response_body=>{"date"=>["cannot be in the past"]}}

If you will input wrong user credentials, and will try to retrieve user token or change something, you will get:

ERROR: No user is logged in

Start

To start using QuickBlox gem just plug it to your project with 

require "quickblox"

To create a new class instance for example type this in Ruby console:

m = Quickblox.new

Methods

Authentication and authorization

get_token

Retrievs token. By default retrieves application token.

Examples:

1.9.2p318 :030 > m.get_token
=> "790ea035931e6ec9262814b9ba17c528809f26b5"
1.9.2p318 :031 > m.get_token("user")
=> "c5906ea2ececd81a0a2e87051a9ab3c2d6e066e2"
1.9.2p318 :032 > m.get_token("device")
=> "82f363188354ebd377c5ae20ede17e5a0817ea77"
1.9.2p318 :033 > m.get_token("user_device")
=> "06285191c4a766eea8368b2192adf8f4c1c10c94"

This method will store token that was retieved last in a global @token, token's type will be stored in a global@token_type

destroy_token

Destroys existing token took from global @token.

Example:

1.9.2p318 :034 > m.destroy_token
 => {:response_code=>"200", :respose=>#<Net::HTTPOK 200 OK readbody=true>, :response_body=>nil}

Token is being destroyed every time the new token of another type is being generated.

Users Module 

get_users_count

Retrieves the quantity of users of the application

Example:

1.9.2p318 :006 >   m.get_users_count
 => 351

get_all_users_list

Retrieves all users' entities of the application Example:

1.9.2p318 :006 >   m.get_all_users_list

The answer is a divided array of users' entities

get_users_list(page,per_page)

Retrieves users with pagination. By default page=1, per_page=10. per_page could not be setmore than 100.

Examle:

1.9.2p318 :002 > m.get_users_list(1,3)
 => {"current_page"=>1, "per_page"=>3, "total_entries"=>351, "items"=>[{"blob_id"=>nil, "created_at"=>"2012-04-02T16:19:12Z", "custom_parameters"=>nil, "email"=>"user3@kozhokaru.com", "external_user_id"=>nil, "facebook_id"=>nil, "full_name"=>nil, "id"=>253, "last_request_at"=>"2012-04-03T13:35:09Z", "login"=>"user3", "owner_id"=>3, "phone"=>nil, "twitter_id"=>nil, "updated_at"=>"2012-04-03T13:35:09Z", "website"=>nil, "tags"=>[{"tag"=>{"id"=>35, "name"=>"emails"}}]}, {"blob_id"=>nil, "created_at"=>"2012-04-02T16:19:13Z", "custom_parameters"=>nil, "email"=>"user4@kozhokaru.com", "external_user_id"=>nil, "facebook_id"=>nil, "full_name"=>nil, "id"=>254, "last_request_at"=>"2012-04-02T16:19:13Z", "login"=>"user4", "owner_id"=>3, "phone"=>nil, "twitter_id"=>nil, "updated_at"=>"2012-04-02T16:19:13Z", "website"=>nil, "tags"=>[{"tag"=>{"id"=>35, "name"=>"emails"}}]}, {"blob_id"=>nil, "created_at"=>"2012-04-02T16:19:13Z", "custom_parameters"=>nil, "email"=>"user5@kozhokaru.com", "external_user_id"=>nil, "facebook_id"=>nil, "full_name"=>nil, "id"=>255, "last_request_at"=>"2012-04-02T16:19:13Z", "login"=>"user5", "owner_id"=>3, "phone"=>nil, "twitter_id"=>nil, "updated_at"=>"2012-04-02T16:19:13Z", "website"=>nil, "tags"=>[{"tag"=>{"id"=>35, "name"=>"emails"}}]}]}

The answer is an array where users' entities are stored in items sub-array

signup_user(user_params)

Creates a new usser of the application. user_params is a hash. Its list could be found by this link. user[owner_id] parameter is set from config.yml, so, you can ignore it.

Example:

m.signup_user(:user=>{:login=>"user2",:password=>"password",:email=>"jake@quickblox.com",:twitter_id=>"234234222",:external_user_id=>55555,:tag_list=>"tag1,tag2,onemoretag",:full_name=>"Captain Jack"})
 => {"user"=>{"blob_id"=>nil, "created_at"=>"2012-04-16T07:30:46Z", "custom_parameters"=>nil, "email"=>"jake@quickblox.com", "external_user_id"=>55555, "facebook_id"=>nil, "full_name"=>"Captain Jack", "id"=>738, "last_request_at"=>"2012-04-16T07:30:46Z", "login"=>"user2", "owner_id"=>3, "phone"=>nil, "twitter_id"=>"234234222", "updated_at"=>"2012-04-16T07:30:46Z", "website"=>nil, "tags"=>[{"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>45, "name"=>"tag1"}}, {"tag"=>{"id"=>46, "name"=>"onemoretag"}}]}}

The answer is an array of the user's entity parameters.

get_user_by_id(id)

Retrieves user by his ID in the system.

Example:

1.9.2p318 :003 > m.get_user_by_id(633)
=> {"user"=>{"blob_id"=>nil, "created_at"=>"2012-04-10T09:50:27Z", "custom_parameters"=>{}, "email"=>"jake@quickblox.com", "external_user_id"=>55555, "facebook_id"=>nil, "full_name"=>"Captain Jack", "id"=>633, "last_request_at"=>"2012-04-10T09:50:27Z", "login"=>"user2", "owner_id"=>3, "phone"=>nil, "twitter_id"=>"234234222", "updated_at"=>"2012-04-10T09:50:27Z", "website"=>nil, "tags"=>[{"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>45, "name"=>"tag1"}}, {"tag"=>{"id"=>46, "name"=>"onemoretag"}}]}}

The answer is an array of the user's entity parameters.

get_user_by_login(login)

Retrieves user by his login name.

Example:

1.9.2p318 :004 > m.get_user_by_login("user2")
 => {"user"=>{"blob_id"=>nil, "created_at"=>"2012-04-10T09:50:27Z", "custom_parameters"=>nil, "email"=>"jake@quickblox.com", "external_user_id"=>55555, "facebook_id"=>nil, "full_name"=>"Captain Jack", "id"=>633, "last_request_at"=>"2012-04-10T09:50:27Z", "login"=>"user2", "owner_id"=>3, "phone"=>nil, "twitter_id"=>"234234222", "updated_at"=>"2012-04-10T09:50:27Z", "website"=>nil, "tags"=>[{"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>45, "name"=>"tag1"}}, {"tag"=>{"id"=>46, "name"=>"onemoretag"}}]}}

The answer is an array of the user's entity parameters.

get_all_users_by_fullname(fullname)

Retrieves all users with given user[fullname] parameter. No pagination.

Example:

1.9.2p318 :006 > m.get_all_users_by_fullname("Captain Jack")
=> [{"blob_id"=>nil, "created_at"=>"2012-04-10T09:50:27Z", "custom_parameters"=>nil, "email"=>"jake@quickblox.com", "external_user_id"=>55555, "facebook_id"=>nil, "full_name"=>"Captain Jack", "id"=>633, "last_request_at"=>"2012-04-10T09:50:27Z", "login"=>"user2", "owner_id"=>3, "phone"=>nil, "twitter_id"=>"234234222", "updated_at"=>"2012-04-10T09:50:27Z", "website"=>nil, "tags"=>[{"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>45, "name"=>"tag1"}}, {"tag"=>{"id"=>46, "name"=>"onemoretag"}}]}]

The answer is an array.

get_users_by_fullname(fullname,page,per_page)

Retrieves users with parameter user[fullname] by page. By default page=1, per_page=10. per_page could not be setmore than 100.

Example:

1.9.2p318 :002 > m.get_users_by_fullname("Captain Jack",1,10)
=> {"user"=>{"current_page"=>1, "per_page"=>10, "total_entries"=>1, "items"=>[{"blob_id"=>nil, "created_at"=>"2012-04-10T09:50:27Z", "custom_parameters"=>nil, "email"=>"jake@quickblox.com", "external_user_id"=>55555, "facebook_id"=>nil, "full_name"=>"Captain Jack", "id"=>633, "last_request_at"=>"2012-04-10T09:50:27Z", "login"=>"user2", "owner_id"=>3, "phone"=>nil, "twitter_id"=>"234234222", "updated_at"=>"2012-04-10T09:50:27Z", "website"=>nil, "tags"=>[{"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>45, "name"=>"tag1"}}, {"tag"=>{"id"=>46, "name"=>"onemoretag"}}]}]}}

The answer is an array where users' details are stored in items sub-array. 

get_user_by_facebook_id(fbid)

Retrieves user with parameter user[facebook_id].

Example:

1.9.2p318 :004 > m.get_user_by_facebook_id("13123123123123")
 => {"user"=>{"blob_id"=>nil, "created_at"=>"2012-04-03T09:34:16Z", "custom_parameters"=>nil, "email"=>"korjik5@korjik.com", "external_user_id"=>232, "facebook_id"=>"13123123123123", "full_name"=>"FullName", "id"=>601, "last_request_at"=>"2012-04-03T09:34:16Z", "login"=>"user100503", "owner_id"=>3, "phone"=>"+123123123", "twitter_id"=>"12312300", "updated_at"=>"2012-04-03T09:34:16Z", "website"=>"http://www.wwww.ww", "tags"=>[{"tag"=>{"id"=>41, "name"=>"teg1"}}, {"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>43, "name"=>"tag3"}}]}}

The answer is an array  with user's details.

get_user_by_twitter_id(twid)

Retrieves user with parameter user[twitter_id].

Example:

1.9.2p318 :006 > m.get_user_by_twitter_id("12312300")
 => {"user"=>{"blob_id"=>nil, "created_at"=>"2012-04-03T09:34:16Z", "custom_parameters"=>nil, "email"=>"korjik5@korjik.com", "external_user_id"=>232, "facebook_id"=>"13123123123123", "full_name"=>"FullName", "id"=>601, "last_request_at"=>"2012-04-03T09:34:16Z", "login"=>"user100503", "owner_id"=>3, "phone"=>"+123123123", "twitter_id"=>"12312300", "updated_at"=>"2012-04-03T09:34:16Z", "website"=>"http://www.wwww.ww", "tags"=>[{"tag"=>{"id"=>41, "name"=>"teg1"}}, {"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>43, "name"=>"tag3"}}]}}

The answer is an array  with user's details.

get_user_by_email(email)

Retrieves user with parameter user[email].

Example:

1.9.2p318 :007 > m.get_user_by_email("korjik5@korjik.com")
 => {"user"=>{"blob_id"=>nil, "created_at"=>"2012-04-03T09:34:16Z", "custom_parameters"=>nil, "email"=>"korjik5@korjik.com", "external_user_id"=>232, "facebook_id"=>"13123123123123", "full_name"=>"FullName", "id"=>601, "last_request_at"=>"2012-04-03T09:34:16Z", "login"=>"user100503", "owner_id"=>3, "phone"=>"+123123123", "twitter_id"=>"12312300", "updated_at"=>"2012-04-03T09:34:16Z", "website"=>"http://www.wwww.ww", "tags"=>[{"tag"=>{"id"=>41, "name"=>"teg1"}}, {"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>43, "name"=>"tag3"}}]}}

The answer is an array  with user's details.

get_all_users_by_tags(tags)

Retrieves all users with tags. No pagination.

Example:

1.9.2p318 :015 > m.get_all_users_by_tags("tag3")
 => [{"blob_id"=>nil, "created_at"=>"2012-04-03T09:34:16Z", "custom_parameters"=>{}, "email"=>"korjik5@korjik.com", "external_user_id"=>232, "facebook_id"=>"13123123123123", "full_name"=>"FullName", "id"=>601, "last_request_at"=>"2012-04-03T09:34:16Z", "login"=>"user100503", "owner_id"=>3, "phone"=>"+123123123", "twitter_id"=>"12312300", "updated_at"=>"2012-04-03T09:34:16Z", "website"=>"http://www.wwww.ww", "tags"=>[{"tag"=>{"id"=>41, "name"=>"teg1"}}, {"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>43, "name"=>"tag3"}}]}, {"blob_id"=>nil, "created_at"=>"2012-04-03T09:36:38Z", "custom_parameters"=>{}, "email"=>"korjik6@korjik.com", "external_user_id"=>232222, "facebook_id"=>"131231203123123", "full_name"=>"FullName", "id"=>603, "last_request_at"=>"2012-04-03T09:36:38Z", "login"=>"user100505", "owner_id"=>3, "phone"=>"+123123123", "twitter_id"=>"12322322300", "updated_at"=>"2012-04-03T09:36:38Z", "website"=>"http://www.wwww.ww", "tags"=>[{"tag"=>{"id"=>41, "name"=>"teg1"}}, {"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>43, "name"=>"tag3"}}]}, {"blob_id"=>nil, "created_at"=>"2012-04-03T09:54:47Z", "custom_parameters"=>{}, "email"=>"korjik7@korjik.com", "external_user_id"=>232222332, "facebook_id"=>nil, "full_name"=>"FullName", "id"=>606, "last_request_at"=>"2012-04-03T09:54:47Z", "login"=>"user100507", "owner_id"=>3, "phone"=>"+123123123", "twitter_id"=>nil, "updated_at"=>"2012-04-03T09:54:47Z", "website"=>"http://www.wwww.ww", "tags"=>[{"tag"=>{"id"=>41, "name"=>"teg1"}}, {"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>43, "name"=>"tag3"}}]}, {"blob_id"=>nil, "created_at"=>"2012-04-03T10:00:59Z", "custom_parameters"=>{}, "email"=>"korjik8@korjik.com", "external_user_id"=>nil, "facebook_id"=>nil, "full_name"=>"FullName", "id"=>607, "last_request_at"=>"2012-04-03T10:00:59Z", "login"=>"user100508", "owner_id"=>3, "phone"=>"+123123123", "twitter_id"=>nil, "updated_at"=>"2012-04-03T10:00:59Z", "website"=>"http://www.wwww.ww", "tags"=>[{"tag"=>{"id"=>41, "name"=>"teg1"}}, {"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>43, "name"=>"tag3"}}]}]

The answer is a list of users that are marked with tag that was asked.

get_users_by_tags(tags,page,per_page)

Retrieves users with tags by page.  By default page=1, per_page=10. per_page could not be setmore than 100.

Example:

1.9.2p318 :002 > m.get_users_by_tags("tag3",3,1)
=> {"current_page"=>3, "per_page"=>1, "total_entries"=>4, "items"=>[{"blob_id"=>nil, "created_at"=>"2012-04-03T09:54:47Z", "custom_parameters"=>{}, "email"=>"korjik7@korjik.com", "external_user_id"=>232222332, "facebook_id"=>nil, "full_name"=>"FullName", "id"=>606, "last_request_at"=>"2012-04-03T09:54:47Z", "login"=>"user100507", "owner_id"=>3, "phone"=>"+123123123", "twitter_id"=>nil, "updated_at"=>"2012-04-03T09:54:47Z", "website"=>"http://www.wwww.ww", "tags"=>[{"tag"=>{"id"=>41, "name"=>"teg1"}}, {"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>43, "name"=>"tag3"}}]}]}

The answer is an array where users' details are stored in items sub-array.

update_user(user_params)

Updates the user under which the application is signed in. user_params is a hash. The list could be get from API description here.

Example:

1.9.2p318 :002 > m.update_user(:user=>{:full_name=>"Major Jack",:twitter_id=>"431213122322323"})
=> {"user"=>{"blob_id"=>nil, "created_at"=>"2012-04-02T16:19:15Z", "custom_parameters"=>{}, "email"=>"user10@kozhokaru.com", "external_user_id"=>nil, "facebook_id"=>nil, "full_name"=>"Major Jack", "id"=>260, "last_request_at"=>"2012-04-10T12:14:24Z", "login"=>"user10", "owner_id"=>3, "phone"=>nil, "twitter_id"=>"431213122322323", "updated_at"=>"2012-04-10T12:14:24Z", "website"=>nil, "tags"=>[{"tag"=>{"id"=>35, "name"=>"emails"}}]}}

The answer is an array of updated user details.

delete_user

Deletes the user under which the application is signed in.

Example:

1.9.2p318 :003 > m.delete_user
 => {:response_code=>"200", :respose=>#<Net::HTTPOK 200 OK readbody=true>, :response_body=>nil}

The answer after deletion is just "200 OK"

get_user_by_external_id(id)

Retrieves user by user[external_user_id] parameter.

Example:

1.9.2p318 :007 > m.get_user_by_external_id(55555)
=> {"user"=>{"blob_id"=>nil, "created_at"=>"2012-04-10T09:50:27Z", "custom_parameters"=>nil, "email"=>"jake@quickblox.com", "external_user_id"=>55555, "facebook_id"=>nil, "full_name"=>"Captain Jack", "id"=>633, "last_request_at"=>"2012-04-10T09:50:27Z", "login"=>"user2", "owner_id"=>3, "phone"=>nil, "twitter_id"=>"234234222", "updated_at"=>"2012-04-10T09:50:27Z", "website"=>nil, "tags"=>[{"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>45, "name"=>"tag1"}}, {"tag"=>{"id"=>46, "name"=>"onemoretag"}}]}}

The answer is an array with user details.

get_external_user_id_by_user_id(id)

Retrieves user[external_user_id] by the user ID.

Example:

1.9.2p318 :009 > m.get_external_id_by_user_id(633)
=> 55555

The answer is an integer value of user[external_user_id]

Location Module

create_geodatum(geodata_params)

Creates geodata entity. geodata_params is a hash. List of params could be found on wiki.

Example:

1.9.2p318 :002 > m.create_geodatum(:geo_data=>{:latitude=>"49.9935",:longitude=>"36.230383",:status=>"Awesome status"})
=> {"geo_data"=>{"application_id"=>1, "created_at"=>"2012-04-10T13:01:03Z", "id"=>170, "latitude"=>"49.9935", "longitude"=>"36.230383", "status"=>"Awesome status", "updated_at"=>"2012-04-10T13:01:03Z", "user_id"=>633, "created_at_timestamp"=>1334062863}}

The answer is an array with newly created geodata details.

get_geodata_by_id(id)

Retrieves geodata details by its ID.

Example:

1.9.2p318 :002 > m.get_geodata_by_id(168)
=> {"application_id"=>1, "created_at"=>"2012-04-10T13:00:02Z", "id"=>168, "latitude"=>"49.9935", "longitude"=>"36.230383", "status"=>"Awesome status", "updated_at"=>"2012-04-10T13:00:02Z", "user_id"=>633, "created_at_timestamp"=>1334062802}

The answer is an array with geodata details.

get_geodata(params)

Retrieves geodata details by params. params is an array. List of params could be found on wiki

1.9.2p318 :002 > m.get_geodata("user.id"=>633,"last_only"=>1)
=> {"current_page"=>1, "per_page"=>10, "total_entries"=>1, "geo_data"=>[{"geo_datum"=>{"application_id"=>1, "created_at"=>"2012-04-10T13:01:03Z", "id"=>170, "latitude"=>"49.9935", "longitude"=>"36.230383", "status"=>"Awesome status", "updated_at"=>"2012-04-10T13:01:03Z", "user_id"=>633, "created_at_timestamp"=>1334062863, "user"=>{"blob_id"=>nil, "created_at"=>"2012-04-10T09:50:27Z", "custom_parameters"=>nil, "email"=>"jake@quickblox.com", "external_user_id"=>55555, "facebook_id"=>nil, "full_name"=>"Captain Jack", "id"=>633, "last_request_at"=>"2012-04-10T13:01:03Z", "login"=>"user2", "owner_id"=>3, "phone"=>nil, "twitter_id"=>"234234222", "updated_at"=>"2012-04-10T13:01:03Z", "website"=>nil, "tags"=>[{"tag"=>{"id"=>42, "name"=>"tag2"}}, {"tag"=>{"id"=>45, "name"=>"tag1"}}, {"tag"=>{"id"=>46, "name"=>"onemoretag"}}]}}}]}

The answer is an array of geodata details stored in geo_data sub-array.

delete_geodata(days)

Deletes geodata. days is an integer value of maximum age of data that must remain in the database after a query.\

Example:

1.9.2p318 :013 > m.delete_geodata(1)
 => {:response_code=>"200", :respose=>#<Net::HTTPOK 200 OK readbody=true>, :response_body=>nil}

The answer is jist "200 OK"

delete_geodata_by_id(id)

Deletes geodata by its ID.

Example:

1.9.2p318 :019 > m.delete_geodata_by_id(172)
 => {:response_code=>"200", :respose=>#<Net::HTTPOK 200 OK readbody=true>, :response_body=>nil}

The answer is jist "200 OK"

create_place(place_params)

Creates a place record. place_params is a hash. The listed parameters could be found on wiki.

Example:

m.create_place(:place=>{:photo_id=>294,:geo_data_id=>210,:title=>"The Title",:description=>"The most awesome description",:address=>"My appartment"})
 => {"place"=>{"address"=>"My appartment", "created_at"=>"2012-04-16T07:38:54Z", "description"=>"The most awesome description", "geo_data_id"=>210, "id"=>105, "photo_id"=>294, "title"=>"The Title", "updated_at"=>"2012-04-16T07:38:54Z", "latitude"=>"49.9935", "longitude"=>"36.230383"}}

Returns an array of newly created place details.

get_places(page,per_page)

Retrieves places with pagination. By default page=1, per_page=10. per_page could not be set more than 100.

Example:

1.9.2p318 :004 > m.get_places
=> {"current_page"=>1, "per_page"=>10, "total_entries"=>7, "items"=>[{"place"=>{"address"=>"", "created_at"=>"2012-03-02T14:24:18Z", "description"=>"dsfsd", "geo_data_id"=>42, "id"=>52, "photo_id"=>49, "title"=>"ssdfs", "updated_at"=>"2012-03-02T14:24:18Z", "latitude"=>"49.3244795834", "longitude"=>"9.89152625"}}, {"place"=>{"address"=>"", "created_at"=>"2012-03-22T14:49:40Z", "description"=>"xcvxcv", "geo_data_id"=>83, "id"=>66, "photo_id"=>90, "title"=>"xcvxcv", "updated_at"=>"2012-03-22T14:49:40Z", "latitude"=>"51.508129", "longitude"=>"-0.128005"}}, {"place"=>{"address"=>"", "created_at"=>"2012-03-22T14:51:10Z", "description"=>"sdfzsdf", "geo_data_id"=>84, "id"=>67, "photo_id"=>91, "title"=>"sdfsdf", "updated_at"=>"2012-03-22T14:51:10Z", "latitude"=>"51.508129", "longitude"=>"-0.128005"}}, {"place"=>{"address"=>"", "created_at"=>"2012-03-22T14:52:10Z", "description"=>"sdfsdf", "geo_data_id"=>85, "id"=>68, "photo_id"=>92, "title"=>"asdfsdfsdf", "updated_at"=>"2012-03-22T14:52:10Z", "latitude"=>"51.508129", "longitude"=>"-0.128005"}}, {"place"=>{"address"=>"", "created_at"=>"2012-03-22T14:56:13Z", "description"=>"SDFSDf", "geo_data_id"=>86, "id"=>69, "photo_id"=>93, "title"=>"sdfsdf", "updated_at"=>"2012-03-22T14:56:13Z", "latitude"=>"51.508129", "longitude"=>"-0.128005"}}, {"place"=>{"address"=>"My appartment", "created_at"=>"2012-04-10T14:09:27Z", "description"=>"The most awesome description", "geo_data_id"=>169, "id"=>98, "photo_id"=>247, "title"=>"The Title", "updated_at"=>"2012-04-10T14:09:27Z", "latitude"=>"49.9935", "longitude"=>"36.230383"}}, {"place"=>{"address"=>"My appartment", "created_at"=>"2012-04-10T14:07:32Z", "description"=>"The most awesome description", "geo_data_id"=>170, "id"=>97, "photo_id"=>247, "title"=>"The Title", "updated_at"=>"2012-04-10T14:07:32Z", "latitude"=>"49.9935", "longitude"=>"36.230383"}}]}

Returns an array of places entities stored in items sub-array.

get_place_by_id(id)

Retrieves place by its ID.

Example:

1.9.2p318 :003 > m.get_places_by_id(67)
=> {"place"=>{"address"=>"", "created_at"=>"2012-03-22T14:51:10Z", "description"=>"sdfzsdf", "geo_data_id"=>84, "id"=>67, "photo_id"=>91, "title"=>"sdfsdf", "updated_at"=>"2012-03-22T14:51:10Z", "latitude"=>"51.508129", "longitude"=>"-0.128005"}}

Returns an array of place details.

update_place_by_id(id,params)

Updates place by its ID. params is a hash. List of params could be found on wiki.

Example:

1.9.2p318 :002 > m.update_place_by_id(100,:place=>{:title=>"The new title",:description=>"Awsome place"})
=> {"place"=>{"address"=>"My appartment", "created_at"=>"2012-04-11T06:29:50Z", "description"=>"Awsome place", "geo_data_id"=>168, "id"=>100, "photo_id"=>247, "title"=>"The new title", "updated_at"=>"2012-04-11T06:30:59Z", "latitude"=>"49.9935", "longitude"=>"36.230383"}}

Returns an array with updated details of the place.

delete_place_by_id(id)

Deletes places by ID.

Example:

1.9.2p318 :003 > m.delete_place_by_id(99)
 => {:response_code=>"200", :respose=>#<Net::HTTPOK 200 OK readbody=true>, :response_body=>nil}

Returns '200 OK'

Content Module

create_file(path,params)

Uploads file. params is a hash. List of params could be found on wiki.

Example:

1.9.2p318 :017 >   m.create_file("/home/korjik/Pictures/download.png",:blob=>{:content_type=>"image/png",:name=>"my image"})
=> {"blob"=>{"blob_status"=>"complete", "content_type"=>"image/png", "created_at"=>"2012-04-10T13:52:39Z", "id"=>247, "last_read_access_ts"=>nil, "lifetime"=>0, "name"=>"my image", "public"=>false, "ref_count"=>1, "set_completed_at"=>nil, "size"=>nil, "tags"=>nil, "uid"=>"f59e561c83fc444c93401803132ab55000", "updated_at"=>"2012-04-10T13:52:39Z", "blob_object_access"=>{"blob_id"=>247, "expires"=>"2012-04-10T14:52:39Z", "id"=>247, "object_access_type"=>"Write", "params"=>"http://blobs-test-oz.s3.amazonaws.com/?AWSAccessKeyId=AKIAJHMRS6ZUIQ6VTQDQ&Policy=eyAiZXhwaXJhdGlvbiI6ICIyMDEyLTA0LTEwVDE0OjUyOjM5WiIsCiAgICAgICJjb25kaXRpb25zIjogWwogICAgICAgIHsiYnVja2V0IjogImJsb2JzLXRlc3Qtb3oifSwKICAgICAgICBbImVxIiwgIiRrZXkiLCAiZjU5ZTU2MWM4M2ZjNDQ0YzkzNDAxODAzMTMyYWI1NTAwMCJdLAogICAgICAgIHsiYWNsIjogImF1dGhlbnRpY2F0ZWQtcmVhZCJ9LAogICAgICAgIFsiZXEiLCAiJENvbnRlbnQtVHlwZSIsICJpbWFnZS9wbmciXSwKICAgICAgICB7InN1Y2Nlc3NfYWN0aW9uX3N0YXR1cyI6ICIyMDEifQogICAgICBdCiAgICB9&Signature=Mz9NqyU6g4dOCz2vgOl%2BV9K5Qzk%3D&key=f59e561c83fc444c93401803132ab55000&Content-Type=image%2Fpng&acl=authenticated-read&success_action_status=201"}}}

Returns uploaded file details.

get_file_info_by_id(id)

Retrieves file info by its ID.

Example:

1.9.2p318 :006 > m.get_file_info_by_id(256)
=> {"blob"=>{"blob_status"=>"complete", "content_type"=>"image/png", "created_at"=>"2012-04-10T15:02:16Z", "id"=>256, "last_read_access_ts"=>"2012-04-10T16:02:20Z", "lifetime"=>0, "name"=>"my image", "public"=>false, "ref_count"=>1, "set_completed_at"=>"2012-04-10T15:02:21Z", "size"=>111, "tags"=>nil, "uid"=>"4883b3a29d574bdc99700fc91713a9bf00", "updated_at"=>"2012-04-10T15:02:21Z"}}

Returns an array of a file details.

get_files_list(page,per_page)

Retrieves all file of the current user by page.  By default page=1, per_page=10. per_page could not be set more than 100.

1.9.2p318 :003 > m.get_files_list(3,3)
=> {"current_page"=>3, "per_page"=>3, "total_entries"=>33, "items"=>[{"blob"=>{"blob_status"=>nil, "content_type"=>"image/png", "created_at"=>"2012-04-10T14:59:26Z", "id"=>253, "last_read_access_ts"=>"2012-04-10T15:59:31Z", "lifetime"=>0, "name"=>"my image", "public"=>false, "ref_count"=>1, "set_completed_at"=>nil, "size"=>nil, "tags"=>nil, "uid"=>"9a56f2150ce94025a07d7d11906440dd00", "updated_at"=>"2012-04-10T14:59:31Z"}}, {"blob"=>{"blob_status"=>"complete", "content_type"=>"image/png", "created_at"=>"2012-04-10T15:00:52Z", "id"=>254, "last_read_access_ts"=>"2012-04-10T16:00:56Z", "lifetime"=>0, "name"=>"my image", "public"=>false, "ref_count"=>1, "set_completed_at"=>"2012-04-10T15:00:56Z", "size"=>111, "tags"=>nil, "uid"=>"8c90454b66b34dc5b3c4d6671e1889c200", "updated_at"=>"2012-04-10T15:00:56Z"}}, {"blob"=>{"blob_status"=>nil, "content_type"=>"image/png", "created_at"=>"2012-04-10T15:01:07Z", "id"=>255, "last_read_access_ts"=>"2012-04-10T16:01:08Z", "lifetime"=>0, "name"=>"my image", "public"=>false, "ref_count"=>1, "set_completed_at"=>nil, "size"=>nil, "tags"=>nil, "uid"=>"3f02945a05b94d819e25607e60686c9f00", "updated_at"=>"2012-04-10T15:01:08Z"}}]}

Returns an array of the page where files' details are stored in the items sub-array. 

get_file_link_by_uid(uid)

Retrieves a link to Amazon S3 by blob[uid] paramter.

Example:

1.9.2p318 :002 > m.get_file_link_by_uid("d33c6e7a6c104919b045723917b734f500")
=> "https://qbprod.s3.amazonaws.com:443/d33c6e7a6c104919b045723917b734f500?Signature=lhMrBsf9iWVwHOnG95r4k9msqhs%3D&Expires=1334132072&AWSAccessKeyId=AKIAJHMRS6ZUIQ6VTQDQ"

Returns a string of link.

get_file_link_by_id(id)

Retrieves a link to Amazon S3 by file ID.

1.9.2p318 :003 > m.get_file_link_by_id(249)
=> "https://qbprod.s3.amazonaws.com:443/d33c6e7a6c104919b045723917b734f500?Signature=qUDtDuoZBYu4uwWrlsBGYWirl3s%3D&Expires=1334132262&AWSAccessKeyId=AKIAJHMRS6ZUIQ6VTQDQ"

Returns a string of link.

edit_file_by_id(id,params)

Edits file by it ID. params is an array of filename that could be changed. It have to look like : "blob[name]"=>"the_new_name"

Example:

1.9.2p318 :002 > m.edit_file_by_id(249,"blob[name]"=>"the_new_name")
=> {"blob"=>{"blob_status"=>"complete", "content_type"=>"image/png", "created_at"=>"2012-04-10T14:53:07Z", "id"=>249, "last_read_access_ts"=>"2012-04-11T08:35:14Z", "lifetime"=>0, "name"=>"the_new_name", "public"=>false, "ref_count"=>0, "set_completed_at"=>"2012-04-10T14:53:09Z", "size"=>111, "tags"=>nil, "uid"=>"d33c6e7a6c104919b045723917b734f500", "updated_at"=>"2012-04-11T09:02:36Z"}}

Returns an array of updated file detatails.

delete_file(id)

Deletes the file by it ID.

Example:

1.9.2p318 :002 > m.delete_file(282)
=> {:response_code=>"200", :respose=>#<Net::HTTPOK 200 OK readbody=true>, :response_body=>nil}

Returns "200 OK"

increase_file_links(id)

Increases file's ref_count

Example:

m.increase_file_links(295)
=> {:response_code=>"200", :respose=>#<Net::HTTPOK 200 OK readbody=true>, :response_body=>nil}

Returns 200 OK.

Messages Module

create_push_token(params)

Creates push token. params is a hash. List of params could be found on wiki.

Example:

1.9.2p318 :002 >  m.create_push_token(:push_token=>{:environment=>"development",:client_identification_sequence=>"http://sn1.notify.live.net/throttledthirdparty/01.00/AAFXSgqZ2XDxQIC1c06wRF9DAgAAAAADAQAAAAQUZm52OjIzOEQ2NDJDRkI5MEVFMEQ"})
 => {"push_token"=>{"client_identification_sequence"=>"http://sn1.notify.live.net/throttledthirdparty/01.00/AAFXSgqZ2XDxQIC1c06wRF9DAgAAAAADAQAAAAQUZm52OjIzOEQ2NDJDRkI5MEVFMEQ", "environment"=>"development", "id"=>51}}

Returns an array of a newly created push token.

create_subscription(channels,url)

Creates subscription to the chosen channels. Url is used only if channel is "http_request", so if channels are another channels, you can ignore it. By default url=nil.

Example:

1.9.2p318 :021 > m.create_subscription("mpns,http_request","api.quckblox.com/123")
 => [{"subscription"=>{"id"=>164, "notification_channel"=>{"name"=>"http_request"}, "device"=>{"udid"=>"1231asdsdf23123ss3ss22", "platform"=>{"name"=>"windows_phone"}}, "request_notification_setting"=>{"url"=>"api.quckblox.com/123"}}}, {"subscription"=>{"id"=>163, "notification_channel"=>{"name"=>"mpns"}, "device"=>{"udid"=>"1231asdsdf23123ss3ss22", "platform"=>{"name"=>"windows_phone"}}}}]

Returns an array of subscriptions that were created.

get_subscriptions

Retrieves subscriptions list of the user and device he signed in at.

Example:

1.9.2p318 :022 > m.get_subscriptions
=> [{"subscription"=>{"id"=>164, "notification_channel"=>{"name"=>"http_request"}, "device"=>{"udid"=>"1231asdsdf23123ss3ss22", "platform"=>{"name"=>"windows_phone"}}, "request_notification_setting"=>{"url"=>"api.quckblox.com/123"}}}, {"subscription"=>{"id"=>163, "notification_channel"=>{"name"=>"mpns"}, "device"=>{"udid"=>"1231asdsdf23123ss3ss22", "platform"=>{"name"=>"windows_phone"}}}}]

Returns an array of subscriptions.

delete_subscription(id)

Deletes subscription by it ID.

Example:

1.9.2p318 :023 > m.delete_subscription(164)
=> {:response_code=>"200", :respose=>#<Net::HTTPOK 200 OK readbody=true>, :response_body=>nil}

Returns "200 OK"

create_event(params,message)

Creates an event - notification or a HTTP request. params is a hash. List of available params could be seen on wiki. message is a custom hash that will described for every type of notification.

Microsoft Push Notification

Sends MPNS message of the following types:

Toast notification

message is a hash:

 :type=>"toast" TOAST WP notification
 :body=>"message body" Message body. Take a look at MSDN for details
 :head=>"message head" Message head
 :return_path=>"/" # Return Path
 :class=>2 X-NotificationClass in headers. 2 = Immediate delivery. 12 = Delivered within 450 seconds. 22 = Delivered within 900 seconds.

Example:

1.9.2p318 :002 > m.create_event({:event=>{:notification_type=>"push",:push_type=>"mpns",:user=>{:ids=>"633"}, :environment=>"development"}},{:type=>"toast",:body=>"message body",:head=>"message head",:return_path=>"/",:class=>2})
 => {"event"=>{"active"=>true, "application_id"=>1, "created_at"=>"2012-04-11T10:50:06Z", "date"=>nil, "end_date"=>nil, "event_type"=>"one_shot", "id"=>666, "message"=>"mpns=PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz48d3A6Tm90aWZpY2F0aW9uIHhtbG5zOndwPSdXUE5vdGlmaWNhdGlvbic+PHdwOlRvYXN0Pjx3cDpUZXh0MT5tZXNzYWdlIGhlYWQ8L3dwOlRleHQxPjx3cDpUZXh0Mj5tZXNzYWdlIGJvZHk8L3dwOlRleHQyPjx3cDpQYXJhbT4vPC93cDpQYXJhbT48L3dwOlRvYXN0Pjwvd3A6Tm90aWZpY2F0aW9uPg==&headers=Q29udGVudC1UeXBlLHRleHQveG1sLFgtTm90aWZpY2F0aW9uQ2xhc3MsMixYLVdpbmRvd3NQaG9uZS1UYXJnZXQsdG9hc3Q=", "name"=>nil, "occured_count"=>0, "period"=>nil, "updated_at"=>"2012-04-11T10:50:06Z", "user_id"=>633, "notification_channel"=>{"name"=>"mpns"}, "subscribers_selector"=>{"environment"=>"development", "tags_query"=>""}}}

Returns an array of a newly created event details.

Tile notifications

message is a hash:

 :type=>"tile" TILE WP notification
 :background_image=>"Blue.jpg" Background image. Take a look at MSDN for details
 :count=>4 Count
 :title=>"FRONT TITLE" Title
 :back_background_image=>"Green.jpg" Back background image
 :back_content=>"312312" Back content
 :back_title=>"BACK TITLE" Back title
 :class=>2 X-NotificationClass in headers. 1 = Immediate delivery. 11 = Delivered within 450 seconds. 21 = Delivered within 900 seconds.

Example:

1.9.2p318 :002 > m.create_event({:event=>{:notification_type=>"push",:push_type=>"mpns",:user=>{:ids=>"633"}, :environment=>"production"}},{:type=>"tile",:background_image=>"Blue.jpg",:count=>4,:title=>"FRONT TITLE",:back_background_image=>"Green.jpg", :back_content=>"312312", :back_title=>"BACK TITLE",:class=>1})
=> {"event"=>{"active"=>true, "application_id"=>1, "created_at"=>"2012-04-11T11:25:55Z", "date"=>nil, "end_date"=>nil, "event_type"=>"one_shot", "id"=>668, "message"=>"mpns=PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz48d3A6Tm90aWZpY2F0aW9uIHhtbG5zOndwPSdXUE5vdGlmaWNhdGlvbic+PHdwOlRpbGU+PHdwOkJhY2tncm91bmRJbWFnZT5CbHVlLmpwZz48L3dwOkJhY2tncm91bmRJbWFnZT48d3A6Q291bnQ+NDwvd3A6Q291bnQ+PHdwOlRpdGxlPkZST05UIFRJVExFPC93cDpUaXRsZT48d3A6QmFja0JhY2tncm91bmRJbWFnZT5HcmVlbi5qcGc8L3dwOkJhY2tCYWNrZ3JvdW5kSW1hZ2U+PHdwOkJhY2tUaXRsZT5CQUNLIFRJVExFPC93cDpCYWNrVGl0bGU+PHdwOkJhY2tDb250ZW50PjMxMjMxMjwvd3A6QmFja0NvbnRlbnQ+PC93cDpUaWxlPjwvd3A6Tm90aWZpY2F0aW9uPg==&headers=Q29udGVudC1UeXBlLHRleHQveG1sLFgtTm90aWZpY2F0aW9uQ2xhc3MsMSxYLVdpbmRvd3NQaG9uZS1UYXJnZXQsdG9rZW4=", "name"=>nil, "occured_count"=>0, "period"=>nil, "updated_at"=>"2012-04-11T11:25:55Z", "user_id"=>633, "notification_channel"=>{"name"=>"mpns"}, "subscribers_selector"=>{"environment"=>"production", "tags_query"=>""}}

Returns newly created event details.

Raw notifications

message is a hash:

 :type=>"raw"  TILE WP notification
 :body=>"Message"  Message body. Take a look at MSDN for details
 :class=>3  X-NotificationClass in headers. 3 = Immediate delivery. 13 = Delivered within 450 seconds. 23 = Delivered within 900 seconds.

Example:

1.9.2p318 :003 > m.create_event({:event=>{:notification_type=>"push",:push_type=>"mpns",:user=>{:ids=>"633"}, :environment=>"production"}},{:type=>"raw",:body=>"Message",:class=>3})
=> {"event"=>{"active"=>true, "application_id"=>1, "created_at"=>"2012-04-11T11:51:39Z", "date"=>nil, "end_date"=>nil, "event_type"=>"one_shot", "id"=>671, "message"=>"mpns=TWVzc2FnZQ==&headers=Q29udGVudC1UeXBlLHRleHQveG1sLFgtTm90aWZpY2F0aW9uQ2xhc3MsMw==", "name"=>nil, "occured_count"=>0, "period"=>nil, "updated_at"=>"2012-04-11T11:51:39Z", "user_id"=>633, "notification_channel"=>{"name"=>"mpns"}, "subscribers_selector"=>{"environment"=>"production", "tags_query"=>""}}

Returns newly created event details.

Android notification

Sends c2dm notification to android device.

message is a hash of :body=>"Message to send"

Example:

1.9.2p318 :026 > m.create_event({:event=>{:notification_type=>"push",:push_type=>"c2dm",:user=>{:ids=>"633"}, :environment=>"production"}},{:body=>'message'})
=> {"event"=>{"active"=>true, "application_id"=>1, "created_at"=>"2012-04-11T12:12:55Z", "date"=>nil, "end_date"=>nil, "event_type"=>"one_shot", "id"=>676, "message"=>"data.message=bWVzc2FnZQ==", "name"=>nil, "occured_count"=>0, "period"=>nil, "updated_at"=>"2012-04-11T12:12:55Z", "user_id"=>633, "notification_channel"=>{"name"=>"c2dm"}, "subscribers_selector"=>{"environment"=>"production", "tags_query"=>""}}

Returns newly created event details.

IOS notification

Sends APNS notification to IOS devices.

message is a hash:

 :alert=>"Message"  Message body. Check out Apple Developer site for more info.
 :badge_counter=>3  Badge counter value
 :sound=>"default" Sound on/off.

Example:

1.9.2p318 :009 > m.create_event({:event=>{:notification_type=>"push",:push_type=>"apns",:user=>{:ids=>"633"}, :environment=>"development"}},{:alert=>"lol",:badge_counter=>3, :sound=>"default"})
=> {"event"=>{"active"=>true, "application_id"=>1, "created_at"=>"2012-04-11T12:34:39Z", "date"=>nil, "end_date"=>nil, "event_type"=>"one_shot", "id"=>682, "message"=>"payload=eyJhcHMiOnsiYWxlcnQiOiJsb2wiLCJiYWRnZSI6Mywic291bmQiOiJkZWZhdWx0In19", "name"=>nil, "occured_count"=>0, "period"=>nil, "updated_at"=>"2012-04-11T12:34:39Z", "user_id"=>633, "notification_channel"=>{"name"=>"apns"}, "subscribers_selector"=>{"environment"=>"development", "tags_query"=>""}}

Returns a newly created event details.

Email notification

Sends email to user

message is a hash:

 :subject=>"Hello!"  Message subject
 :body=>"Message"   Message body

Example:

1.9.2p318 :002 > m.create_event({:event=>{:notification_type=>"email",:user=>{:ids=>"633"}, :environment=>"development"}},{:body=>'Message',:subject=>"Subject"})
=> {"event"=>{"active"=>true, "application_id"=>1, "created_at"=>"2012-04-12T10:00:48Z", "date"=>nil, "end_date"=>nil, "event_type"=>"one_shot", "id"=>689, "message"=>"subject=U3ViamVjdA==&body=TWVzc2FnZQ==", "name"=>nil, "occured_count"=>0, "period"=>nil, "updated_at"=>"2012-04-12T10:00:48Z", "user_id"=>633, "notification_channel"=>{"name"=>"email"}, "subscribers_selector"=>{"environment"=>"development", "tags_query"=>""}}

Returns a newly created event details.

Pull request

Creates a pull request event.

message is a hash and consists only from body:  :body=>"Please pull me!"

Example:

m.create_event({:event=>{:notification_type=>"pull",:date=>1334226795,:end_date=>1334227795,:user=>{:ids=>"254"}, :environment=>"development"}},{:body=>"Messagee",:subject=>"new"})
=> {"event"=>{"active"=>true, "application_id"=>1, "created_at"=>"2012-04-12T10:17:16Z", "date"=>1334226795, "end_date"=>1334227795, "event_type"=>"multi_shot", "id"=>690, "message"=>"subject=Tm90aWZpY2F0aW9uIGZyb20ga29yamlr&body=TWVzc2FnZQ==", "name"=>nil, "occured_count"=>0, "period"=>nil, "updated_at"=>"2012-04-12T10:17:16Z", "user_id"=>633, "notification_channel"=>{"name"=>"pull"}, "subscribers_selector"=>{"environment"=>"development", "tags_query"=>""}}

Returns a newly created event details.

HTTP request

Sends POST request to the URL registered in a subscription.

message is a hash of POST fields:

 :subject=>"Hello!"   Subject POST field
 :body=>"valiue"    Body POST field
 :params=>"field1=value1&field2=value2&field3=value3"  Custom POST fields and values devided by &

Example:

1.9.2p318 :002 > m.create_event({:event=>{:notification_type=>"http_request",:user=>{:ids=>"633"}, :environment=>"development"}},{:body=>'asd',:subject=>"subject",:params=>"param1=value1&param2=value2"})
=> {"event"=>{"active"=>true, "application_id"=>1, "created_at"=>"2012-04-12T12:32:49Z", "date"=>nil, "end_date"=>nil, "event_type"=>"one_shot", "id"=>726, "message"=>"subject=subject&body=asd&param1=value1&param2=value2", "name"=>nil, "occured_count"=>0, "period"=>nil, "updated_at"=>"2012-04-12T12:32:49Z", "user_id"=>633, "notification_channel"=>{"name"=>"http_request"}, "subscribers_selector"=>{"environment"=>"development", "tags_query"=>""}}

Returns a newly created event details.

get_events(page,per_page)

Retrives event list by page. By default page=1,per_page=10. per_page could not be set more than 100.

Example:

1.9.2p318 :005 > m.get_events(3,2)
=> {"current_page"=>3, "per_page"=>2, "total_entries"=>64, "items"=>[{"events"=>{"active"=>false, "application_id"=>1, "created_at"=>"2012-04-11T11:24:23Z", "date"=>nil, "end_date"=>nil, "event_type"=>"one_shot", "id"=>667, "message"=>"mpns=PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz48d3A6Tm90aWZpY2F0aW9uIHhtbG5zOndwPSdXUE5vdGlmaWNhdGlvbic+PHdwOlRpbGU+PHdwOkJhY2tncm91bmRJbWFnZT5SZWQuanBnPjwvd3A6QmFja2dyb3VuZEltYWdlPjx3cDpDb3VudD40PC93cDpDb3VudD48d3A6VGl0bGU+RlIgVElUTEU8L3dwOlRpdGxlPjx3cDpCYWNrQmFja2dyb3VuZEltYWdlPkdyZWVuLmpwZzwvd3A6QmFja0JhY2tncm91bmRJbWFnZT48d3A6QmFja1RpdGxlPkJBQ0sgVElUTEU8L3dwOkJhY2tUaXRsZT48d3A6QmFja0NvbnRlbnQ+MzEyMzEyPC93cDpCYWNrQ29udGVudD48L3dwOlRpbGU+PC93cDpOb3RpZmljYXRpb24+&headers=Q29udGVudC1UeXBlLHRleHQveG1sLFgtTm90aWZpY2F0aW9uQ2xhc3MsMSxYLVdpbmRvd3NQaG9uZS1UYXJnZXQsdG9rZW4=", "name"=>nil, "occured_count"=>1, "period"=>nil, "updated_at"=>"2012-04-11T11:24:31Z", "user_id"=>633, "notification_channel"=>{"name"=>"mpns"}, "subscribers_selector"=>{"environment"=>"production", "tags_query"=>""}}}, {"events"=>{"active"=>false, "application_id"=>1, "created_at"=>"2012-04-11T11:25:55Z", "date"=>nil, "end_date"=>nil, "event_type"=>"one_shot", "id"=>668, "message"=>"mpns=PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz48d3A6Tm90aWZpY2F0aW9uIHhtbG5zOndwPSdXUE5vdGlmaWNhdGlvbic+PHdwOlRpbGU+PHdwOkJhY2tncm91bmRJbWFnZT5CbHVlLmpwZz48L3dwOkJhY2tncm91bmRJbWFnZT48d3A6Q291bnQ+NDwvd3A6Q291bnQ+PHdwOlRpdGxlPkZST05UIFRJVExFPC93cDpUaXRsZT48d3A6QmFja0JhY2tncm91bmRJbWFnZT5HcmVlbi5qcGc8L3dwOkJhY2tCYWNrZ3JvdW5kSW1hZ2U+PHdwOkJhY2tUaXRsZT5CQUNLIFRJVExFPC93cDpCYWNrVGl0bGU+PHdwOkJhY2tDb250ZW50PjMxMjMxMjwvd3A6QmFja0NvbnRlbnQ+PC93cDpUaWxlPjwvd3A6Tm90aWZpY2F0aW9uPg==&headers=Q29udGVudC1UeXBlLHRleHQveG1sLFgtTm90aWZpY2F0aW9uQ2xhc3MsMSxYLVdpbmRvd3NQaG9uZS1UYXJnZXQsdG9rZW4=", "name"=>nil, "occured_count"=>1, "period"=>nil, "updated_at"=>"2012-04-11T11:26:01Z", "user_id"=>633, "notification_channel"=>{"name"=>"mpns"}, "subscribers_selector"=>{"environment"=>"production", "tags_query"=>""}}}]}

Returns an array of events in iterms sub-array.

edit_event(id,prams,message)

Edits the event. Looks very similar to create_event method. If you want to send the same message just leave it bloank:

Examples:

1.9.2p318 :011 > m.edit_event(728,{:event=>{:active=>true}},{:alert=>"Message",:badge_counter=>3, :sound=>"default"})
=> {"event"=>{"active"=>true, "application_id"=>1, "created_at"=>"2012-04-12T13:52:03Z", "date"=>nil, "end_date"=>nil, "event_type"=>"one_shot", "id"=>728, "message"=>"payload=eyJhcHMiOnsiYWxlcnQiOiJNZXNzYWdlIiwiYmFkZ2UiOjMsInNvdW5kIjoiZGVmYXVsdCJ9fQ==", "name"=>nil, "occured_count"=>7, "period"=>nil, "updated_at"=>"2012-04-12T14:21:09Z", "user_id"=>633, "notification_channel"=>{"name"=>"apns"}, "subscribers_selector"=>{"environment"=>"development", "tags_query"=>""}}
1.9.2p318 :012 > m.edit_event(728,{:event=>{:active=>true}})
=> {"event"=>{"active"=>true, "application_id"=>1, "created_at"=>"2012-04-12T13:52:03Z", "date"=>nil, "end_date"=>nil, "event_type"=>"one_shot", "id"=>728, "message"=>"payload=eyJhcHMiOnsiYWxlcnQiOiJNZXNzYWdlIiwiYmFkZ2UiOjMsInNvdW5kIjoiZGVmYXVsdCJ9fQ==", "name"=>nil, "occured_count"=>8, "period"=>nil, "updated_at"=>"2012-04-12T14:21:38Z", "user_id"=>633, "notification_channel"=>{"name"=>"apns"}, "subscribers_selector"=>{"environment"=>"development", "tags_query"=>""}}

If you want to resend MPNS message with changing its body, you should put the same message details as in create_event method and also add MPNS message type as :type=>"tile" for example:

1.9.2p318 :020 > m.edit_event(670,{:event=>{:active=>true}},{:body=>"Message body",:type=>"raw",:class=>3})
=> {"event"=>{"active"=>true, "application_id"=>1, "created_at"=>"2012-04-11T11:50:56Z", "date"=>nil, "end_date"=>nil, "event_type"=>"one_shot", "id"=>670, "message"=>"mpns=TWVzc2FnZSBib2R5&headers=Q29udGVudC1UeXBlLHRleHQveG1sLFgtTm90aWZpY2F0aW9uQ2xhc3MsMw==", "name"=>nil, "occured_count"=>3, "period"=>nil, "updated_at"=>"2012-04-12T14:52:05Z", "user_id"=>633, "notification_channel"=>{"name"=>"mpns"}, "subscribers_selector"=>{"environment"=>"production", "tags_query"=>""}}

Returns an array of a newly created event details.

delete_event(id)

Deletes event by it ID.

Examples:

1.9.2p318 :022 > m.delete_event(670)
=> {:response_code=>"200", :respose=>#<Net::HTTPOK 200 OK readbody=true>, :response_body=>nil}

Returns "200 OK"

get_event_by_id(id)

Retrieves event details by its ID.

1.9.2p318 :024 > m.get_event_by_id(669)
=> {"event"=>{"active"=>false, "application_id"=>1, "created_at"=>"2012-04-11T11:49:51Z", "date"=>nil, "end_date"=>nil, "event_type"=>"one_shot", "id"=>669, "message"=>"mpns=PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz5iYmJi&headers=Q29udGVudC1UeXBlLHRleHQveG1sLFgtTm90aWZpY2F0aW9uQ2xhc3MsMw==", "name"=>nil, "occured_count"=>1, "period"=>nil, "updated_at"=>"2012-04-11T11:50:01Z", "user_id"=>633, "notification_channel"=>{"name"=>"mpns"}, "subscribers_selector"=>{"environment"=>"production", "tags_query"=>""}}

Returns an array of event details.

get_pull_request_list

Retrievs pull requests list.

Example:

1.9.2-p318 :013 > m.get_pull_request_list
=> [{"event"=>{"active"=>true, "application_id"=>1, "created_at"=>"2012-04-12T15:32:37Z", "date"=>1334244836, "end_date"=>1335234706, "event_type"=>"multi_shot", "id"=>741, "message"=>"subject=dXBkYXRl&body=TWVzc2FnZQ==", "name"=>nil, "occured_count"=>1, "period"=>nil, "updated_at"=>"2012-04-12T15:33:58Z", "user_id"=>633, "notification_channel"=>{"name"=>"pull"}, "subscribers_selector"=>{"environment"=>"development", "tags_query"=>""}}}]

Returns an array of event details. 

Ratings module

create_gamemode(title)

Creates an array of a new game mode named with title.

Example:

1.9.2p318 :003 > m.create_gamemode("The gamemode")
=> {"game_mode"=>{"application_id"=>1, "id"=>260, "title"=>"The gamemode", "user_id"=>254}}

Returns a new game mode details.

update_gamemode(id,title)

Updates existing gamemode's title by ID.

Example:

1.9.2p318 :002 > m.update_gamemode(260,"The gamemode title")
=> {"game_mode"=>{"application_id"=>1, "id"=>260, "title"=>"The gamemode title", "user_id"=>254}}

Returns an array of a game mode details.

get_gamemode_by_id(id)

Retrieves gamemode details by ID.

Example:

1.9.2p318 :002 > m.get_gamemode_by_id(260)
=> {"game_mode"=>{"application_id"=>1, "id"=>260, "title"=>"The gamemode title", "user_id"=>254}}

Returns an array of a game mode details.

get_gamemodes

Retrieves application gamemode list

Example:

1.9.2p318 :002 > m.get_gamemodes
=> [{"game_mode"=>{"application_id"=>1, "id"=>256, "title"=>"New gamemode", "user_id"=>254}}, {"game_mode"=>{"application_id"=>1, "id"=>257, "title"=>"New new  gamemode", "user_id"=>254}}, {"game_mode"=>{"application_id"=>1, "id"=>258, "title"=>"New new  gamemode2", "user_id"=>254}}, {"game_mode"=>{"application_id"=>1, "id"=>259, "title"=>"New new  gamemode3", "user_id"=>254}}, {"game_mode"=>{"application_id"=>1, "id"=>260, "title"=>"The gamemode title", "user_id"=>254}}]

Returns an array of gamemodes' details.

delete_gamemode(id)

Deletes gamemode by ID

Example:

1.9.2p318 :004 > m.delete_gamemode(265)
=> {:response_code=>"200", :respose=>#<Net::HTTPOK 200 OK readbody=true>, :response_body=>nil}

Returns HTTP OK

create_score(params)

Creates score. Param's' is a hash. Its items are listed on wiki.

Example:

1.9.2p318 :002 > m.create_score(:score=>{:game_mode_id=>266, :value=>2232})
 => {"score"=>{"created_at"=>"2012-04-16T07:00:54Z", "game_mode_id"=>266, "id"=>188, "user_id"=>254, "value"=>2232}}

Returns an array of a newly created score details.

update_score(id,params)

Updates score by ID.

Example:

1.9.2p318 :002 > m.update_score(188,:score=>{:game_mode_id=>266, :value=>222322})
=> {"score"=>{"created_at"=>"2012-04-16T07:00:54Z", "game_mode_id"=>266, "id"=>188, "user_id"=>254, "value"=>222322}}

Returns an array of updated score details.

get_score_by_id(id)

Retrieves score by ID.

Example:

1.9.2p318 :002 > m.get_score_by_id(188)
=> {"score"=>{"created_at"=>"2012-04-16T07:00:54Z", "game_mode_id"=>266, "id"=>188, "user_id"=>254, "value"=>222322}}

Returns an array of score details.

get_top_scores(game_mode_id, page, per_page, filters, sort)

Retrieves top scores with gamemode ID.  Only gamemode ID is required. By default page=1, per_page=10, filters=nil, sort=1. Filters description is avaliable on wiki.

Example:

1.9.2p318 :011 > m.get_top_scores(266,2,2)
=> {"current_page"=>2, "per_page"=>2, "total_entries"=>6, "items"=>[{"score"=>{"created_at"=>"2012-04-16T07:19:36Z", "game_mode_id"=>266, "id"=>190, "user_id"=>254, "value"=>2238, "game_mode_parameter_values"=>[]}}, {"score"=>{"created_at"=>"2012-04-16T07:19:33Z", "game_mode_id"=>266, "id"=>189, "user_id"=>254, "value"=>2236, "game_mode_parameter_values"=>[]}}]}

Returns an array of score details stored in items sub-array.

get_scores_for_user(id, sort_by,filters,sort)

Retrieves scores for user by ID. Only user ID is requered. sort_by = "value", filters=nil, sort=1. Filters description is avaliable on wiki.

Example:

1.9.2p318 :003 > m.get_scores_for_user(254)
=> {"current_page"=>1, "per_page"=>10, "total_entries"=>6, "items"=>[{"score"=>{"created_at"=>"2012-04-16T07:19:40Z", "game_mode_id"=>266, "id"=>192, "user_id"=>254, "value"=>2322228, "game_mode_parameter_values"=>[]}}, {"score"=>{"created_at"=>"2012-04-16T07:00:54Z", "game_mode_id"=>266, "id"=>188, "user_id"=>254, "value"=>222322, "game_mode_parameter_values"=>[]}}, {"score"=>{"created_at"=>"2012-04-16T07:19:36Z", "game_mode_id"=>266, "id"=>190, "user_id"=>254, "value"=>2238, "game_mode_parameter_values"=>[]}}, {"score"=>{"created_at"=>"2012-04-16T07:19:33Z", "game_mode_id"=>266, "id"=>189, "user_id"=>254, "value"=>2236, "game_mode_parameter_values"=>[]}}, {"score"=>{"created_at"=>"2012-04-16T06:59:44Z", "game_mode_id"=>266, "id"=>187, "user_id"=>254, "value"=>2232, "game_mode_parameter_values"=>[]}}, {"score"=>{"created_at"=>"2012-04-16T07:19:38Z", "game_mode_id"=>266, "id"=>191, "user_id"=>254, "value"=>238, "game_mode_parameter_values"=>[]}}]}

Returns an array of score details stored in items sub-array.

get_average_scores(game_mode_id)

Retrieves average scores value by gamemode ID.

Example:

1.9.2p318 :004 > m.get_average_scores(266)
=> {"value"=>"425249.0"}

Returns an array of an average scores value.

get_averege_scores_by_app

Retrieves avereage scores of the application that user is logged in.

Example: 

1.9.2p318 :013 > m.get_average_scores_by_app
=> [{"game_mode_id"=>266, "value"=>"425249.0"}, {"game_mode_id"=>267, "value"=>"27479554.5"}, {"game_mode_id"=>268, "value"=>"526621211.0"}]

Returns an array of game modes with top values,

delete_score(id)

Delete score by ID.

1.9.2p318 :016 > m.delete_score(196)
=> {:response_code=>"200", :response_header=>#<Net::HTTPOK 200 OK readbody=true>, :response_body=>nil}

Returns 200 OK

create_gamemodeparameter(params)

Creates a game mode parameter. params is a hash. params values list could be found on wiki.

Example:

1.9.2p318 :011 > m.create_gamemodeparameter(:gamemodeparameter=>{:game_mode_id=>268,:name=>"GMPname"})
 => {"game_mode_parameter"=>{"game_mode_id"=>268, "id"=>281, "name"=>"GMPname"}}

Returns an array of a newly created game mode parameter details.

update_gamemodeparameter(id,params)

Updates a game mode parameter by its ID. params is a hash.  params values list could be found on wiki.

Example:

1.9.2p318 :010 > m.update_gamemodeparameter(280,:gamemodeparameter=>{:game_mode_id=>267,:name=>"NewGMPname"})
=> {"game_mode_parameter"=>{"game_mode_id"=>267, "id"=>280, "name"=>"NewGMPname"}}

Returns an array of a game mode parameter details.

get_gamemodeparameter_by_id(id)

Retrieves game mode parameter by ID.

Example:

1.9.2p318 :013 > m.get_gamemodeparameter_by_id(280)
=> {"game_mode_parameter"=>{"game_mode_id"=>267, "id"=>280, "name"=>"NewGMPname"}}

Returns an array of a game mode parameter details.

get_gamemodeparameter_by_gamemode_id(id)

Retrieves game mode parameter by gamemode ID.

Example:

1.9.2p318 :021 > m.get_gamemodeparameter_by_gamemode_id(268)
=> [{"game_mode_parameter"=>{"game_mode_id"=>268, "id"=>281, "name"=>"GMPname"}}, {"game_mode_parameter"=>{"game_mode_id"=>268, "id"=>282, "name"=>"GMPname1"}}, {"game_mode_parameter"=>{"game_mode_id"=>268, "id"=>283, "name"=>"GMPname2"}}, {"game_mode_parameter"=>{"game_mode_id"=>268, "id"=>284, "name"=>"GMPname3"}}]

Returns an array of game modes parameters details.

delete_gamemodeparameter(id)

Deletes game mode parameter by its ID.

Example:

1.9.2p318 :022 > m.delete_gamemodeparameter(284)
=> {:response_code=>"200", :response_header=>#<Net::HTTPOK 200 OK readbody=true>, :response_body=>nil}

Returns 200 OK.

create_gamemodeparametervalue(params)

Creates a game mode parameter value. params is a hash. List of params could be found on wiki.

Example:

1.9.2p318 :004 > m.create_gamemodeparametervalue(:gamemodeparametervalue=>{:game_mode_parameter_id=>285,:score_id=>198,:value=>2222})
=> {"game_mode_parameter_value"=>{"created_at"=>"2012-04-16T11:15:56Z", "game_mode_parameter_id"=>285, "id"=>179, "score_id"=>198, "value"=>"2222"}}

Returns an array of a newly created game mode parameter value details.

update_gamemodeparametervalue(id, params)

Updates a game mode parameter value by ID. params is a hash. List of params could be found on wiki.

Example:

1.9.2p318 :002 > m.update_gamemodeparametervalue(179, :gamemodeparametervalue=>{:game_mode_parameter_id=>285,:score_id=>198,:value=>22555})
=> {"game_mode_parameter_value"=>{"created_at"=>"2012-04-16T11:15:56Z", "game_mode_parameter_id"=>285, "id"=>179, "score_id"=>198, "value"=>"22555"}}

Returns an array of a game mode parameter value details.

get_gamemodeparametervalue_by_id(id)

Retrives a game mode parameter value by ID.

Example:

1.9.2p318 :007 > m.get_gamemodeparametervalue_by_id(179)
=> {"game_mode_parameter_value"=>{"created_at"=>"2012-04-16T11:15:56Z", "game_mode_parameter_id"=>285, "id"=>179, "score_id"=>198, "value"=>"22555"}}

Returns an array of a game mode parameter value details.

get_gamemodeparametervalue_by_score_id(id)

Retrives a game mode parameter values by a score ID.

Example:

1.9.2p318 :008 > m.get_gamemodeparametervalue_by_score_id(198)
=> [{"game_mode_parameter_value"=>{"created_at"=>"2012-04-16T11:13:29Z", "game_mode_parameter_id"=>282, "id"=>177, "score_id"=>198, "value"=>"2222"}}, {"game_mode_parameter_value"=>{"created_at"=>"2012-04-16T11:15:17Z", "game_mode_parameter_id"=>283, "id"=>178, "score_id"=>198, "value"=>"2222"}}, {"game_mode_parameter_value"=>{"created_at"=>"2012-04-16T11:15:56Z", "game_mode_parameter_id"=>285, "id"=>179, "score_id"=>198, "value"=>"22555"}}]

Returns an array of a game mode parameter values details.

get_api_gamemodeparametervalue_by_score_id (score_id,prameter_id)

Retrives an game mode parameter values by a score ID and a game mode parameter ID.

Example:

1.9.2p318 :002 > m.get_api_gamemodeparametervalue_by_score_id(198,283)
=> {"game_mode_parameter_value"=>{"created_at"=>"2012-04-16T11:15:17Z", "game_mode_parameter_id"=>283, "id"=>178, "score_id"=>198, "value"=>"2222"}}

Returns an array of a game mode parameter values details.

delete_gamemodeparemetervalue(id)

Deletes game mode parameter value by its ID.

Example:

1.9.2p318 :003 > m.delete_gamemodeparametervalue(178)
=> {:response_code=>"200", :response_header=>#<Net::HTTPOK 200 OK readbody=true>, :response_body=>nil}

Returns 200 OK.