facebook_digit_auth 0.0.11 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10bf1a92ca08a0539035e40d7b7dfbd9d230905f
4
- data.tar.gz: 45b118789dd880c502f86bc7d930081c30873e21
3
+ metadata.gz: 1bd37f47354f00cfa045e08a31f202905d09247c
4
+ data.tar.gz: 7f095151687ccd018af879d5ca5be7caa394a0b4
5
5
  SHA512:
6
- metadata.gz: 737b45c25a02ce37130eaa46d47faeefa07ae949aa8684ec7745a725c8c6674705c57e189f6e0d62d4ec50f9d4a699763d1683ac9d14ba26c274c3d4e3cbf0f9
7
- data.tar.gz: a302bc666546c339e403e22340a03dea123370deebb00d2464b2cf286b3790e8875941baea5077254255331144d01fa873573814f7b74ed5478738851917f16b
6
+ metadata.gz: f099d9229714d647851a5692180f88665bc22f999fba69cb56305918d98a062983815038f8cdd7b7668b2db5beba0a0e856a72f89201bb6b5c29a151c270205c
7
+ data.tar.gz: 1ce5ef1ce978ee317a3360c7cdc5988bd78a6691fe73bbc6ab3160777102f75420b62667fff397f2e412ff27201d70cace6d6c7b03774bbd3501e89f21a8c0f4
@@ -33,5 +33,4 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "bundler", "~> 1.13"
34
34
  spec.add_development_dependency "rake", "~> 10.0"
35
35
  spec.add_development_dependency "koala"
36
- spec.add_dependency "httparty"
37
36
  end
@@ -1,3 +1,3 @@
1
1
  module FacebookDigitAuth
2
- VERSION = "0.0.11"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,14 +1,9 @@
1
1
  require "facebook_digit_auth/version"
2
2
 
3
- module FacebookDigitAuth
4
- class Fd
5
- def self.test_method(params,type)
6
- if type == 'facebook'
7
- FacebookClient.new(params).data
8
- elsif type == 'digit'
9
- DigitsClient.new(params).data
10
- end
11
- end
12
- end
3
+ module FacebookDigitAuth
4
+
5
+ def self.test_method
6
+ puts "Here is first line for my gem"
7
+ end
13
8
 
14
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook_digit_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RaghavSingh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-13 00:00:00.000000000 Z
11
+ date: 2016-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: httparty
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  description: You can use this gem when using authentication by facebook and digits.
70
56
  email:
71
57
  - Raghav.Singh@lptpl.com
@@ -82,8 +68,6 @@ files:
82
68
  - bin/console
83
69
  - bin/setup
84
70
  - facebook_digit_auth.gemspec
85
- - lib/digit_client.rb
86
- - lib/facebook_client.rb
87
71
  - lib/facebook_digit_auth.rb
88
72
  - lib/facebook_digit_auth/version.rb
89
73
  homepage: https://github.com/RaghavVishnoi/test_gem.git
data/lib/digit_client.rb DELETED
@@ -1,41 +0,0 @@
1
- require 'httparty'
2
-
3
- class DigitsClient
4
- def initialize(digit_params)
5
- @digits_credentials = digit_params
6
- @user_id = digit_params[:user_id]
7
- @phone_no = digit_params[:number]
8
- @auth_token = digit_params[:auth_token]
9
- @auth_token_secret = digit_params[:auth_token_secret]
10
- @auth_headers = digit_params[:auth_headers]
11
- end
12
-
13
- def data
14
- if verified
15
- {result: true,data: response}
16
- else
17
- {result: false,message: "Wrong credentials supplied!"}
18
- end
19
- end
20
-
21
- def response
22
- HTTParty.get(url, :headers => header)
23
- end
24
-
25
- def verified
26
- if response["phone_number"] != @phone_no || response["id_str"] != @user_id || response["access_token"]["token"] != @auth_token || response["access_token"]["secret"] != @auth_token_secret
27
- false
28
- else
29
- true
30
- end
31
- end
32
-
33
- def header
34
- {"Authorization" => @auth_headers['X-Verify-Credentials-Authorization']}
35
- end
36
-
37
- def url
38
- @auth_headers["X-Auth-Service-Provider"]
39
- end
40
-
41
- end
@@ -1,141 +0,0 @@
1
- class FacebookClient
2
-
3
- def initialize(token)
4
- @client = Koala::Facebook::API.new(token)
5
- end
6
-
7
- def data
8
- {
9
- "id": user_id,
10
- "birthday": birthday,
11
- "first_name": first_name,
12
- "last_name": last_name,
13
- "email": email,
14
- "work": work,
15
- "education": education,
16
- "gender": gender,
17
- "age": age,
18
- "token_for_business": token_for_business,
19
- "facebook_friend_ids": facebook_friend_ids,
20
- "profile_picture": profile_picture
21
-
22
- }
23
- end
24
-
25
- def user_id
26
- basic_information["id"]
27
- end
28
-
29
- def birthday
30
- if basic_information["birthday"].present?
31
- Date.strptime(basic_information["birthday"], "%m/%d/%Y")
32
- else
33
- ""
34
- end
35
- end
36
-
37
- def first_name
38
- basic_information["first_name"]
39
- end
40
-
41
- def last_name
42
- basic_information["last_name"]
43
- end
44
-
45
- def email
46
- basic_information["email"]
47
- end
48
-
49
- def work
50
- if basic_information["work"].present?
51
- work = basic_information["work"][0]
52
- if work["position"]
53
- "#{work["position"]["name"]} at #{work["employer"]["name"]}"
54
- else
55
- "#{work["employer"]["name"]}"
56
- end
57
- else
58
- ""
59
- end
60
- end
61
-
62
- def education
63
- if basic_information["education"].present?
64
- education = basic_information["education"]
65
- if education.length != 0
66
- education.last['school']['name']
67
- else
68
- "Education not mentioned!"
69
- end
70
- end
71
- end
72
-
73
- def gender
74
- if basic_information["gender"].present?
75
- basic_information["gender"]
76
- else
77
- "notspecified"
78
- end
79
- end
80
-
81
- def age
82
- if basic_information["birthday"].present?
83
- Date.today.year - Date.strptime(basic_information["birthday"], "%m/%d/%Y").year
84
- else
85
- 0
86
- end
87
- end
88
-
89
- def token_for_business
90
- business_token_info["token_for_business"]
91
- end
92
-
93
- def facebook_friend_ids
94
- friends_response.map { |friend| friend["id"] }
95
- end
96
-
97
- def mutual_friends(facebook_user_id)
98
- get_mutual_friends(facebook_user_id)
99
- end
100
-
101
- def profile_picture
102
- photo_url(basic_information["facebook_user_id"])
103
- end
104
-
105
- private
106
-
107
- attr_reader :client
108
-
109
- def basic_information
110
- @basic_information ||= client.get_object("me")
111
- end
112
-
113
- def user_context(facebook_user_id)
114
- context = client.get_object("#{facebook_user_id}?fields=context")
115
- end
116
-
117
- def get_mutual_friends(facebook_user_id)
118
- context = user_context(facebook_user_id)
119
- mutual_friends = client.get_object("#{context["context"]["id"]}?fields=all_mutual_friends.fields(picture.width(100).height(100), name)")
120
- if mutual_friends["all_mutual_friends"]
121
- mutual_friends["all_mutual_friends"]["data"].map{|friend| {"name" => friend["name"], "profile_picture_url" => friend["picture"]["data"]["url"]}}
122
- else
123
- []
124
- end
125
- end
126
-
127
- def business_token_info
128
- @business_token_info ||= client.get_object("me?fields=token_for_business")
129
- end
130
-
131
- def friends_response
132
- @friends_response ||= client.get_connections("me", "friends?limit=5000")
133
- puts @friends_response.inspect
134
- @friends_response ||= client.get_connections("me", "friends?limit=5000")
135
- end
136
-
137
- def photo_url(facebook_user_id)
138
- "http://graph.facebook.com/v2.3/#{facebook_user_id}/picture" +
139
- "?height=500&width=500"
140
- end
141
- end