deviceatlasapi 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjU2MTM1YjRhMmNkMDJhYTdlY2JjOGI1MmIyYTNkMGRlZDYzNWQxMw==
4
+ ZDgyMWI1NjA0Y2IyZTFhMjhhYzk4ODhlNjZhZDA1NjQ3ZTkwNDJjOA==
5
5
  data.tar.gz: !binary |-
6
- NjU5ZDczNzYwYmU2ZGYyNGJkZDlmN2I4YjAyZTM5Y2Y3ZGM5Yzg3MQ==
6
+ NDIxM2RhYjBkMDFmMTAzYzI5ZjgxNTdhMDQ2Nzc0ODg3ZTVkMDQ4Mg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MDI0YmEyY2YwYjdmMTZkZmJiMGJmNjYzZTA3MDg0OGU3YWY0YTg1OTE3OWY0
10
- Mzk2MTM2OGVjM2FkNGQzMDFmMzdmNzhiYzllZmZjYTA1YjE3NzMwMTBkYzcz
11
- NGE0NjYwYjIxNjkwZDI0M2FhZGUxYWRkM2FmMmFjNzI1MDYxZTU=
9
+ ZjJhYmZmYzJkY2E4OGViMTkxYzhkZTU5M2UyNzQ0ZTM3MGI5ODI0MmIxMmRj
10
+ YmMwZTg1MzRlZGVlYzU1MDFlZTg5NmI3NzJkMDIyMGQxOTU2YmYwYmE5MTBk
11
+ MTEyYmU5MTc5NWI2NTNiNmNiOTU4M2I5ZTU2YzNjNGYzNDRjZmE=
12
12
  data.tar.gz: !binary |-
13
- MTNjNTA4MjY0NjdlMGVmODFhMzE5OWY2MzlhZDU5NzI0OWQxNmQ1OWQwOTE0
14
- OGI0MzFhMjc3OTYyZTEyMzA2MTA2M2IzZjE5OTgxZjI5ZDQ5ODNhNGYwMDVk
15
- YmRiOWRjMDhmY2U1YjMyM2Y1YmQ5MDZiMzc2NTljNzY0OGVmMTM=
13
+ Yzc2YWEzOGQwYmQ0YjBlMTE0NTQxYjc5Nzc1ZmNjZDM1ODYyNTYxYzcwZjNj
14
+ NDY2MTkwZTQ5OWYyYzAxYjhmOTQxYjkxODVlNTI4OWU0ZWMwZTdlZDRhNWZl
15
+ YzUwMDdlNTdjMjFiZGQzYWRjYmI4ZWE1YWY3NDliNzlkNzJmY2E=
@@ -2,7 +2,7 @@ module DeviceAtlasApi
2
2
  module ControllerHelpers
3
3
 
4
4
  def get_device_data
5
- client = DeviceAtlasApi::Client.new(request.env['HTTP_USER_AGENT'])
5
+ client = DeviceAtlasApi::Client.new(request)
6
6
  client.get_device_data
7
7
  end
8
8
 
@@ -1,3 +1,3 @@
1
1
  module DeviceAtlasApi
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -9,22 +9,40 @@ module DeviceAtlasApi
9
9
  yield self
10
10
  end
11
11
 
12
-
13
12
  class Client
14
13
 
15
- def initialize user_agent
16
- @user_agent = user_agent
14
+ def initialize request
15
+ @user_agent = request.env['HTTP_USER_AGENT']
16
+ @headers = prepare_headers request
17
17
  @cloud_host = 'api.deviceatlascloud.com'
18
18
  end
19
19
 
20
20
  def get_device_data
21
- HTTParty.get("http://#{@cloud_host}/#{prepare_request_header}")["properties"]
21
+ url = prepare_url
22
+ HTTParty.get(url, @headers)["properties"]
22
23
  end
23
24
 
24
25
  private
25
26
 
26
- def prepare_request_header
27
- "/v1/detect/properties?licencekey=#{ENV['DEVICE_ATLAS_LICENCE_KEY']}&useragent=#{URI.escape(@user_agent)}"
27
+ def prepare_headers request
28
+ {
29
+ 'HTTP_X_PROFILE' => request.env['HTTP_X_PROFILE'],
30
+ 'HTTP_X_WAP_PROFILE' => request.env['HTTP_X_WAP_PROFILE'],
31
+ 'HTTP_X_ATT_DEVICEID' => request.env['HTTP_X_ATT_DEVICEID'],
32
+ 'HTTP_ACCEPT' => request.env['HTTP_ACCEPT'],
33
+ 'HTTP_ACCEPT_LANGUAGE' => request.env['HTTP_ACCEPT_LANGUAGE'],
34
+ 'HTTP_X_DEVICE_USER_AGENT' => request.env['HTTP_X_DEVICE_USER_AGENT'],
35
+ 'HTTP_X_ORIGINAL_USER_AGENT' => request.env['HTTP_X_ORIGINAL_USER_AGENT'],
36
+ 'HTTP_X_OPERAMINI_PHONE_UA' => request.env['HTTP_X_OPERAMINI_PHONE_UA'],
37
+ 'HTTP_X_SKYFIRE_PHONE' => request.env['HTTP_X_SKYFIRE_PHONE'],
38
+ 'HTTP_X_BOLT_PHONE_UA' => request.env['HTTP_X_BOLT_PHONE_UA'],
39
+ 'HTTP_DEVICE_STOCK_UA' => request.env['HTTP_DEVICE_STOCK_UA'],
40
+ 'HTTP_X_UCBROWSER_DEVICE_UA' => request.env['HTTP_X_UCBROWSER_DEVICE_UA'],
41
+ }
42
+ end
43
+
44
+ def prepare_url
45
+ "http://#{@cloud_host}/v1/detect/properties?licencekey=#{ENV['DEVICE_ATLAS_LICENCE_KEY']}&useragent=#{URI.escape(@user_agent)}"
28
46
  end
29
47
  end
30
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deviceatlasapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trevor Kimenye
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-09 00:00:00.000000000 Z
11
+ date: 2013-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler