Skip to content

Commit

Permalink
Converted to PHP 8 and oAuth
Browse files Browse the repository at this point in the history
  • Loading branch information
SamanthaAdrichem committed Mar 3, 2023
1 parent 3c03877 commit df7a633
Show file tree
Hide file tree
Showing 16 changed files with 1,148 additions and 365 deletions.
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Project specific
daisycon-api-token.json
test.php
opt/**

# Generic
.externalToolBuilders
.project
.buildpath
.settings
.phpunit.result.cache
tmp/
.DS_Store
/data
/conf
/vendor/*
*.php.pid
**/nbproject
**.pid
**/*.pid
.editorconfig
*.komodo*
.idea
/_windows
/inspection
colors.scheme.xml
databaseDrivers.xml
debugger.xml
diff.xml
ide.general.xml
ignore.xml
IntelliLang.xml
web-browsers.xml
logs/

# Windows image file caches
Thumbs.db
51 changes: 31 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
{
"name": "samanthaadrichem/daisycon-api",
"type": "library",
"description": "Quick Daisycon Api Helper Class",
"keywords": [
"Daisycon",
"Api"
],
"authors": [
{
"name": "Samantha Adrichem"
}
],
"require": {
"ext-curl": "*",
"ext-json": "*",
"php": ">=5.5"
},
"autoload": {
"psr-0": { "DaisyconApi\\": "library/" }
}
"name": "samanthaadrichem/daisycon-api",
"type": "library",
"description": "Quick Daisycon Api Helper Class",
"keywords": [
"Daisycon",
"Api"
],
"authors": [
{
"name": "Samantha Adrichem"
}
],
"autoload": {
"psr-4": {
"SamanthaAdrichem\\DaisyconApi\\": "library/"
}
},
"config": {
"platform": {
"php": "8.1.6"
},
"process-timeout": 1800,
"sort-packages": true
},
"require": {
"php": "^8.1",
"ext-curl": "*",
"ext-json": "*",
"daisyconbv/oauth-examples": "^1.0",
"symfony/serializer": "6.1.1"
}
}
235 changes: 235 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions examples.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

use SamanthaAdrichem\DaisyconApi\Exception\Http\NotFoundException;
use SamanthaAdrichem\DaisyconApi\Exception\Http\HttpException;
use SamanthaAdrichem\DaisyconApi\MethodEnum;
use SamanthaAdrichem\DaisyconApi\RestClient;

// Setup client

$restClient = new RestClient(
'myClientId',
'myClientSecret'
);

// Fetch my publisher account
var_dump($restClient->getPublishers());

// Fetch my publisher Ids
var_dump($restClient->getPublisherIds());

// Fetch my advertiser account
var_dump($restClient->getAdvertisers());

// Fetch my advertiser Ids
var_dump($restClient->getAdvertiserIds());

// Fetch my lead generation account
var_dump($restClient->getLeadGeneration());

// Fetch my lead generation Ids
var_dump($restClient->getLeadGenerationIds());

// Catch errors
try
{
$restClient->performCall('/some/non/existing/url');
}
// There are specific types, you can catch per type
catch (NotFoundException $exception)
{
var_dump($exception->getMessage());
}
// Or just catch all HttpExceptions
catch (HttpException $exception)
{
var_dump($exception->getMessage());
}
// Or just all exceptions
catch (Exception $exception)
{
var_dump($exception->getMessage());
}

// You can also check the last response code
var_dump($restClient->getLastResponseCode());

// Get the response headers
$responseHeaders = [];
$restClient->performCall(
'/some/existing/url',
MethodEnum::Get,
[],
$responseHeaders
);
var_dump($responseHeaders);

// Enable sandbox mode
$restClient->enableSandboxMode();
Loading

0 comments on commit df7a633

Please sign in to comment.