coc Rb

CocRb

Welcome everyone to your Ruby Gem CocRb. By using this gem you can easily interact with the Game API of Clash of Clans without using any external gems to call this API.

Installation

Add this line to your application's Gemfile:

gem 'cocRb'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install cocRb

Usage

CocRb Gem is categorized with Classes and Methods as below down you can see but before accessing any of those we have to set Configuration in order to setup the Authorization for accessing the Clash of Clans API so to do that we have set Configure block and inside that block we have configured our TOKEN and the URL.

token = <Your_Token>
requestUrl = <Your_Url>

CocRb.configure do |config|
     config.token = token
     config.url = requestUrl
end

After done setting up the Authorization we now need to call the API as you can see down below we called the API using call_API method now just before that line we have set the class ClashApi by name_spacing with CocRb Module.

Note: All the data that we will get from the API reponse was in JSON but since you are using this gem all of the responses has been parsed to Ruby Hashes so that its get easy for you to access the data.

set_Class = CocRb::ClashApi

response = set_Class.call_API

puts response

# data from the API in Ruby Hashes...

The API can also be called without using the URL in the Configuration block the way you can do is shown down below. As you can we have almost followed the same procedure like we did before just changed few things those are we have removed the config.url line, We now have called a new class and a method. This method now takes two parameters one is your Player Tag and another thing is your Player API Token which you will find In-Game Settings.

The Detailed info about all the Classes and Methods for this Library can be found in our Documentation.


CocRb.configure do |config|
     config.token = token
end

set_var = CocRb::Player   

response = set_var.verify_PlayerByToken(tag: "#PG8RLGQ2", playertoken: "7jeagw4c")

# Response => {"tag"=>"#PG8RLGQ2", "token"=>"7jeagw4c", "status"=>"ok"}

License

The gem is available as open source under the terms of the MIT License.