barcher 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/barcher.rb +51 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2c30cafbf881f1cf6286fd4c316aefb8e085abb2
4
+ data.tar.gz: cf05ffe00596b960b80a962b1fef94db20fb9f8e
5
+ SHA512:
6
+ metadata.gz: c9c17e74cc4b46d8f321b218c809b8d2669b1e3a031814246d7bbd85e5df046c9cf5d48dda8b49d1df7239634ff26e1754b222c1954585fa157ee5e49bd02fb0
7
+ data.tar.gz: 4c5599265c289ae40dc3c768c0f582d0a0b53fcdbf92d4ca521e2996c687464570ac002a42fbfbe8892a43191fd4e987d4452f061aea16436faf9d832e3f4205
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+
4
+ module Barcher
5
+ class Client
6
+ include HTTParty
7
+ API_ENDPOINT = "https://api.clashofclans.com/v1"
8
+
9
+ def initialize(options={})
10
+ self.class.base_uri API_ENDPOINT
11
+ self.class.headers "Accept" => "application/json", "authorization" => "Bearer #{options[:token]}"
12
+ end
13
+
14
+ def clan_search(options={})
15
+ #valid_options = %i{name war_frequency location_id min_members min_clan_points min_clan_level limit after before}
16
+ self.class.get("/clans", camelize_options(options))
17
+ end
18
+
19
+ def find_clan(clan_tag)
20
+ self.class.get("/clans/#{clan_tag}")
21
+ end
22
+
23
+ def clan_members_for(clan_tag)
24
+ self.class.get("/clans/#{clan_tag}/members")
25
+ end
26
+
27
+ def locations
28
+ self.class.get("/locations")
29
+ end
30
+
31
+ def location(id)
32
+ self.class.get("/locations/#{id}")
33
+ end
34
+
35
+ def rankings_at_location(location_id, ranking_id)
36
+ self.class.get("/locations/#{location_id}/rankings/#{ranking_id}")
37
+ end
38
+
39
+ def leagues
40
+ self.class.get("/leagues")
41
+ end
42
+
43
+ # TODO: move out of here or use ActiveSupport
44
+ def camelize_options(options)
45
+ options.dup.each do |k,v|
46
+ options[k.to_s.split('_').inject([]){|c,word| c.push(c.empty? ? word : word.capitalize)}.join] = v
47
+ end
48
+ end
49
+
50
+ end
51
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: barcher
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Harris
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Simple ruby client for the Clash of Clans API
14
+ email: brandon@brandon-harris.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/barcher.rb
20
+ homepage: https://github.com/bbwharris/barcher
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.5.1
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Ruby Client for the Clash of Clans API
44
+ test_files: []