2017 © Pedro PelĂĄez
 

library codecombat-api

Package for codecombat.com REST API

image

timutech/codecombat-api

Package for codecombat.com REST API

  • Monday, May 14, 2018
  • by xanmanza
  • Repository
  • 1 Watchers
  • 0 Stars
  • 83 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 22 Versions
  • 19 % Grown

The README.md

codecombat-api

PHP package for CodeCombat REST API

codecombat-api is a package for the CodeCombat REST API. It provides an abstracted interface to talk with the CodeCombat API. The Package contains a Laravel ServiceProvider to inject it into the Laravel Service Container, but other than that the package is framework-agnostic. Please look at the CodeCombat API Documentation for more details and do not be afraid to peruse the source code on this package., (*1)

Installation

composer require timutech/codecombat-api, (*2)

Configuration

You will preferably need to have your own OAuth2 server. You will need to have a lookup URL where CodeCombat can query an AccessToken you give them and then you will return the User on your system linked to that AccessToken. eg https://yoursite.com/api/auth/{token} which returns a User with a required id field., (*3)

Normal

Make sure you keep your CodeCombat OAuth {CLIENT_ID}, {CLIENT_SECRET} and {OAUTH_PROVIDER_ID} in whatever config you have as you will need it to instantiate an instance., (*4)

Laravel

Add the line TimuTech\CodeCombat\CodeCombatserviceProvider::class, like below in your config/app.php file., (*5)

'providers' => [
    // Other

    TimuTech\CodeCombat\CodeCombatServiceProvider::class,
],

Add your CodeCombat OAuth credentials to your config/services.php file, as below., (*6)

// Other services

'codecombat' => [
    'id' => '{CLIENT_ID}',
    'secret' => '{CLIENT_SECRET}',
    'provider_id' => '{OAUTH_PROVIDER_ID}'
]

Usage

Refer to the source code for other functionality or create a pull request for addition of functionality. I will endeavour to keep adding features whenever I can., (*7)

Normal

Instantiate, (*8)

$codecombat = new CodeCombat(
    {CLIENT_ID},
    {CLIENT_SECRET},
    {OAUTH_PROVIDER_ID});

Create a new user, (*9)

$user = {A user from your system}
$combatUser = $codecombat->register([
    'name' => $user->name, // UNIQUE Nick Name
    'email' => $user->email, // NEW Email,
    'role' => 'student' //or 'teacher'
]);

Assign an OAuth Identity, (*10)

$token = {YOUR OAuth2 token, generated for your user from your server}
$codecombat->setAuth($token)->createIdentity($combatUser);

Retrieve the user later, (*11)

$handle = {UNIQUE Nick Name assigned earlier or the CodeCombat ID of the user, if you have it}
$combatUser = $codecombat->getUser($handle);

Get the url to redirect to CodeCombat, (*12)

$token = {YOUR OAuth2 token, generated for your user from your server}
$url = $codecombat->setAuth($token)->redirect();

The TimuTech\CodeCombat\Resources\CombatUser class has some helpful methods and attributes, to name a few:, (*13)

$combatUser->getEmail();
$combatUser->getId();
$combatUser->getProfile();

Once again, the source code is your friend., (*14)

The Versions

14/05 2018

dev-master

9999999-dev

Package for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

29/03 2018

v0.5.2

0.5.2.0

Package for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

07/01 2018

v0.5.1

0.5.1.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

10/06 2017

v0.5.0

0.5.0.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

10/06 2017

v0.4.6

0.4.6.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

10/06 2017

v0.4.5

0.4.5.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

10/06 2017

v0.4.4

0.4.4.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

10/06 2017

v0.4.3

0.4.3.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

10/06 2017

v0.4.2

0.4.2.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

08/06 2017

v0.4.1

0.4.1.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

08/05 2017

v0.3.1

0.3.1.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

08/05 2017

v0.4.0

0.4.0.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

05/05 2017

v0.3.0

0.3.0.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

20/04 2017

v0.2.5

0.2.5.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

20/04 2017

v0.2.4

0.2.4.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

19/04 2017

v0.2.3

0.2.3.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

17/04 2017

v0.2.2

0.2.2.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

17/04 2017

v0.2.1

0.2.1.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

17/04 2017

v0.2.0

0.2.0.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

16/04 2017

v0.1.3

0.1.3.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

by Alexander Glöss

16/04 2017

v0.1.2

0.1.2.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires

 

16/04 2017

v0.1.1

0.1.1.0

SDK for codecombat.com REST API

  Sources   Download

MIT

The Requires