botman / driver-facebook

BotMan Facebook Messenger Driver
MIT License
71 stars 73 forks source link

Add userinfo to user object #6

Closed christophrumpel closed 7 years ago

christophrumpel commented 7 years ago

This PR adds all the available FB user info to the new user_info property.

codecov[bot] commented 7 years ago

Codecov Report

Merging #6 into master will increase coverage by 0.61%. The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master       #6      +/-   ##
============================================
+ Coverage     79.54%   80.15%   +0.61%     
- Complexity      231      236       +5     
============================================
  Files            25       26       +1     
  Lines           611      630      +19     
============================================
+ Hits            486      505      +19     
  Misses          125      125
Impacted Files Coverage Δ Complexity Δ
src/FacebookDriver.php 85.15% <100%> (ø) 41 <0> (-2) :arrow_down:
src/FacebookUser.php 100% <100%> (ø) 7 <7> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1f6065b...427b68d. Read the comment docs.

mpociot commented 7 years ago

@christophrumpel can you create a new FacebookUser object that gives access to the new fields? It can just extend the normal user object.

christophrumpel commented 7 years ago

There you go. Here is an example on how to test it.

PS: Is there a way that the IDE knows about the FB specific methods too? (see image attached)

screen shot 2017-07-31 at 08 22 58
// Simple respond method
        $botman->hears('Hello', function (BotMan $bot) {
            $user = $bot->getUser();
            $bot->reply('Hi there :)'
                . ' Firstname: '. $bot->getUser()->getFirstName()
                . ' lastname: '. $bot->getUser()->getLastName()
                . ' Profile Pic: '. json_encode($bot->getUser()->getProfilePic())
                . ' Locale: '. $bot->getUser()->getLocale()
                . ' timezone: '. $bot->getUser()->getTimezone()
                . ' gender: '. $bot->getUser()->getGender()
                . ' getIsPaymentEnabled: '. $bot->getUser()->getIsPaymentEnabled()
                . ' getLastAdReferral: '. json_encode($bot->getUser()->getLastAdReferral()));
        });
mpociot commented 7 years ago

Love it, thank you!