facebook_digit_auth 0.1.1.pre.beta.pre.1 → 0.1.1.pre.beta.pre.2

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: c78694a1f182db31ba8feb08aad1bfb96754ac9f
4
- data.tar.gz: 122e2a7351f49a17c2c96c7b2e66755dbbd56ee3
3
+ metadata.gz: 3fda7294100a92b673ca5d38cc942b6180ac01b3
4
+ data.tar.gz: 2d0a1f99905bd8db5495fed5944ca104bff5cc94
5
5
  SHA512:
6
- metadata.gz: f58afec4a584e92beb6808d0d6cb7309f210180b78769c4fef0d7c51fcda9049fe2056edad83a8a071368e9236661ea78097cfac8ceefc760f620268c67c5793
7
- data.tar.gz: 176e43888fd1dec82fb2094bb372afa08958e3ad75de5ae3a02eeec62a8d46ba84ae2b2a9f056220150d6475d3f5f397a40f31664c31afd29f60ba2cb374cfe0
6
+ metadata.gz: 245ce531432b9a5541a0a224779bb00f365636e017319e4493b83785d71ad047c1cf44583bbdba76e6ed4eb10c56a71f0b84160f84d5319a3fa1fefcd2b151ad
7
+ data.tar.gz: eb256d2a5ec054700d61a873312b6217f442f6e66bd750fc156ac220858b0ab5d1860055db64ea8faf877417b25c326ac4fb5041fac263cf21f1adb0330541a4
@@ -1,3 +1,3 @@
1
1
  module FacebookDigitAuth
2
- VERSION = "0.1.1-beta-1"
2
+ VERSION = "0.1.1-beta-2"
3
3
  end
@@ -3,149 +3,9 @@ require "facebook_digit_auth/version"
3
3
  class FacebookDigitAuth
4
4
 
5
5
  def test_method(facebook_user_token)
6
- FacebookClient.data(facebook_user_token)
6
+ FacebookClient.new(facebook_user_token).data
7
7
  end
8
8
 
9
- class FacebookClient
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
9
 
150
10
 
151
11
  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.1
4
+ version: 0.1.1.pre.beta.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - RaghavSingh