facebook_digit_auth 0.1.1.pre.beta.pre.7 → 0.1.1.pre.beta.pre.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/digit_client.rb +41 -0
- data/lib/facebook_digit_auth/version.rb +1 -1
- data/lib/facebook_digit_auth.rb +6 -145
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec5981c3d9416bfc72ed630d87526913ca2ac30d
|
4
|
+
data.tar.gz: bbb1a5ba95e76d2b6e32c3be8763a04a7b7d8ac5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36b9b2f1c2662ded7a690b02a89fdfa2146aa6f3172dc2f23a057a0a846de9b2bfbc5f1eba6c91511ef2f0e6f98f96066b922ed6f5964518ca045e9a81acc777
|
7
|
+
data.tar.gz: ee6247dd1b7cd02f271442d96e63fe73424680805943b0fb18f96f37b15fc2c441cadf9ad6af64da6aa695c6968dd88fd9392cd651a80faa593011961aeb839d
|
data/lib/digit_client.rb
ADDED
@@ -0,0 +1,41 @@
|
|
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
|
data/lib/facebook_digit_auth.rb
CHANGED
@@ -1,151 +1,12 @@
|
|
1
1
|
require "facebook_digit_auth/version"
|
2
2
|
module FacebookDigitAuth
|
3
3
|
|
4
|
-
def test_method(
|
5
|
-
|
4
|
+
def test_method(params,type)
|
5
|
+
if type == 'facebook'
|
6
|
+
FacebookClient.new(params).data
|
7
|
+
elsif type == 'digit'
|
8
|
+
DigitsClient.new(params).data
|
9
|
+
end
|
6
10
|
end
|
7
11
|
|
8
|
-
class FacebookClient
|
9
|
-
|
10
|
-
def initialize(token)
|
11
|
-
@client = Koala::Facebook::API.new(token)
|
12
|
-
end
|
13
|
-
|
14
|
-
def data
|
15
|
-
{
|
16
|
-
"id": user_id,
|
17
|
-
"birthday": birthday,
|
18
|
-
"first_name": first_name,
|
19
|
-
"last_name": last_name,
|
20
|
-
"email": email,
|
21
|
-
"work": work,
|
22
|
-
"education": education,
|
23
|
-
"gender": gender,
|
24
|
-
"age": age,
|
25
|
-
"token_for_business": token_for_business,
|
26
|
-
"facebook_friend_ids": facebook_friend_ids,
|
27
|
-
"profile_picture": profile_picture
|
28
|
-
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
def user_id
|
33
|
-
basic_information["id"]
|
34
|
-
end
|
35
|
-
|
36
|
-
def birthday
|
37
|
-
if basic_information["birthday"].present?
|
38
|
-
Date.strptime(basic_information["birthday"], "%m/%d/%Y")
|
39
|
-
else
|
40
|
-
""
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def first_name
|
45
|
-
basic_information["first_name"]
|
46
|
-
end
|
47
|
-
|
48
|
-
def last_name
|
49
|
-
basic_information["last_name"]
|
50
|
-
end
|
51
|
-
|
52
|
-
def email
|
53
|
-
basic_information["email"]
|
54
|
-
end
|
55
|
-
|
56
|
-
def work
|
57
|
-
if basic_information["work"].present?
|
58
|
-
work = basic_information["work"][0]
|
59
|
-
if work["position"]
|
60
|
-
"#{work["position"]["name"]} at #{work["employer"]["name"]}"
|
61
|
-
else
|
62
|
-
"#{work["employer"]["name"]}"
|
63
|
-
end
|
64
|
-
else
|
65
|
-
""
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def education
|
70
|
-
if basic_information["education"].present?
|
71
|
-
education = basic_information["education"]
|
72
|
-
if education.length != 0
|
73
|
-
education.last['school']['name']
|
74
|
-
else
|
75
|
-
"Education not mentioned!"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def gender
|
81
|
-
if basic_information["gender"].present?
|
82
|
-
basic_information["gender"]
|
83
|
-
else
|
84
|
-
"notspecified"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def age
|
89
|
-
if basic_information["birthday"].present?
|
90
|
-
Date.today.year - Date.strptime(basic_information["birthday"], "%m/%d/%Y").year
|
91
|
-
else
|
92
|
-
0
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def token_for_business
|
97
|
-
business_token_info["token_for_business"]
|
98
|
-
end
|
99
|
-
|
100
|
-
def facebook_friend_ids
|
101
|
-
friends_response.map { |friend| friend["id"] }
|
102
|
-
end
|
103
|
-
|
104
|
-
def mutual_friends(facebook_user_id)
|
105
|
-
get_mutual_friends(facebook_user_id)
|
106
|
-
end
|
107
|
-
|
108
|
-
def profile_picture
|
109
|
-
photo_url(basic_information["facebook_user_id"])
|
110
|
-
end
|
111
|
-
|
112
|
-
private
|
113
|
-
|
114
|
-
attr_reader :client
|
115
|
-
|
116
|
-
def basic_information
|
117
|
-
@basic_information ||= client.get_object("me")
|
118
|
-
end
|
119
|
-
|
120
|
-
def user_context(facebook_user_id)
|
121
|
-
context = client.get_object("#{facebook_user_id}?fields=context")
|
122
|
-
end
|
123
|
-
|
124
|
-
def get_mutual_friends(facebook_user_id)
|
125
|
-
context = user_context(facebook_user_id)
|
126
|
-
mutual_friends = client.get_object("#{context["context"]["id"]}?fields=all_mutual_friends.fields(picture.width(100).height(100), name)")
|
127
|
-
if mutual_friends["all_mutual_friends"]
|
128
|
-
mutual_friends["all_mutual_friends"]["data"].map{|friend| {"name" => friend["name"], "profile_picture_url" => friend["picture"]["data"]["url"]}}
|
129
|
-
else
|
130
|
-
[]
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
def business_token_info
|
135
|
-
@business_token_info ||= client.get_object("me?fields=token_for_business")
|
136
|
-
end
|
137
|
-
|
138
|
-
def friends_response
|
139
|
-
@friends_response ||= client.get_connections("me", "friends?limit=5000")
|
140
|
-
puts @friends_response.inspect
|
141
|
-
@friends_response ||= client.get_connections("me", "friends?limit=5000")
|
142
|
-
end
|
143
|
-
|
144
|
-
def photo_url(facebook_user_id)
|
145
|
-
"http://graph.facebook.com/v2.3/#{facebook_user_id}/picture" +
|
146
|
-
"?height=500&width=500"
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
|
151
12
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facebook_digit_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1.pre.beta.pre.
|
4
|
+
version: 0.1.1.pre.beta.pre.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RaghavSingh
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- bin/console
|
69
69
|
- bin/setup
|
70
70
|
- facebook_digit_auth.gemspec
|
71
|
+
- lib/digit_client.rb
|
71
72
|
- lib/facebook_client.rb
|
72
73
|
- lib/facebook_digit_auth.rb
|
73
74
|
- lib/facebook_digit_auth/version.rb
|