-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added missing segments API calls (v11) (#178)
* added segments api calls * php cs fixer fix * moved to phpdoc payload array * fix erros * fix errors * introduce dto * introduce dto * introduce dto * fixes * removed general purpose pagination dto * requested changes * requested changes * requested changes * requested changes * requested changes * requested changes * removed [] * added filters dto * added filters dto * added filters dto * fixes * added missing relation key * moved value to extra params * added relation constants * introduce separate dtos for every filter type * renamed filters * change request * change request * namespace change to singular * namespace change to singular * move operands to abstract class * null check filters * fix * added response objects * added response objects * added exception handling * added exception handling * added exception handling * added request and response to exception * added request and response to exception - fixes * added separate makeRequest method * added separate makeRequest method * added separate makeRequest method * added separate makeRequest method * added list and delete segments tests * added requested changes * removed unused method * changes * added test for create segment
- Loading branch information
1 parent
1e1ddf8
commit af80fa0
Showing
28 changed files
with
1,097 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OneSignal\Dto; | ||
|
||
interface AbstractDto | ||
{ | ||
public function toArray(): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OneSignal\Dto\Filter; | ||
|
||
use OneSignal\Dto\AbstractDto; | ||
|
||
abstract class AbstractFilter implements AbstractDto | ||
{ | ||
public const GT = '>'; | ||
|
||
public const LT = '<'; | ||
|
||
public const EQ = '='; | ||
|
||
public const NEQ = '!='; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OneSignal\Dto\Filter; | ||
|
||
final class AmountSpentFilter extends AbstractFilter | ||
{ | ||
public const GT = '>'; | ||
|
||
public const LT = '<'; | ||
|
||
public const EQ = '='; | ||
|
||
/** | ||
* @var self::GT|self::LT|self::EQ | ||
*/ | ||
protected string $relation; | ||
|
||
/** | ||
* @var int|float | ||
*/ | ||
protected $value; | ||
|
||
/** | ||
* @param self::GT|self::LT|self::EQ $relation | ||
* @param int|float $value | ||
*/ | ||
public function __construct(string $relation, $value) | ||
{ | ||
$this->relation = $relation; | ||
$this->value = $value; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'field' => 'amount_spent', | ||
'relation' => $this->relation, | ||
'value' => $this->value, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OneSignal\Dto\Filter; | ||
|
||
final class AppVersionFilter extends AbstractFilter | ||
{ | ||
/** | ||
* @var self::GT|self::LT|self::EQ|self::NEQ | ||
*/ | ||
protected string $relation; | ||
|
||
protected string $value; | ||
|
||
/** | ||
* @param self::GT|self::LT|self::EQ|self::NEQ $relation | ||
*/ | ||
public function __construct(string $relation, string $value) | ||
{ | ||
$this->relation = $relation; | ||
$this->value = $value; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'field' => 'app_version', | ||
'relation' => $this->relation, | ||
'value' => $this->value, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OneSignal\Dto\Filter; | ||
|
||
final class BoughtSkuFilter extends AbstractFilter | ||
{ | ||
/** | ||
* @var self::GT|self::LT|self::EQ | ||
*/ | ||
protected string $relation; | ||
|
||
protected string $key; | ||
|
||
/** | ||
* @var int|float | ||
*/ | ||
protected $value; | ||
|
||
/** | ||
* @param self::GT|self::LT|self::EQ $relation | ||
* @param int|float $value | ||
*/ | ||
public function __construct(string $relation, string $key, $value) | ||
{ | ||
$this->relation = $relation; | ||
$this->key = $key; | ||
$this->value = $value; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'field' => 'bought_sku', | ||
'relation' => $this->relation, | ||
'key' => $this->key, | ||
'value' => $this->value, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OneSignal\Dto\Filter; | ||
|
||
final class ConditionalFilter extends AbstractFilter | ||
{ | ||
public const AND = 'AND'; | ||
|
||
public const OR = 'OR'; | ||
|
||
/** | ||
* @var self::AND|self::OR | ||
*/ | ||
protected string $operator; | ||
|
||
/** | ||
* @param self::AND|self::OR $operator | ||
*/ | ||
public function __construct(string $operator) | ||
{ | ||
$this->operator = $operator; | ||
} | ||
|
||
/** | ||
* @param self::AND|self::OR $operator | ||
*/ | ||
public function setOperator(string $operator): self | ||
{ | ||
$this->operator = $operator; | ||
|
||
return $this; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'operator' => $this->operator, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OneSignal\Dto\Filter; | ||
|
||
final class CountryFilter extends AbstractFilter | ||
{ | ||
protected string $value; | ||
|
||
public function __construct(string $value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'field' => 'country', | ||
'relation' => self::EQ, | ||
'value' => $this->value, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OneSignal\Dto\Filter; | ||
|
||
final class FirstSessionFilter extends AbstractFilter | ||
{ | ||
/** | ||
* @var self::GT|self::LT | ||
*/ | ||
protected string $relation; | ||
|
||
/** | ||
* @var int|float | ||
*/ | ||
protected $hoursAgo; | ||
|
||
/** | ||
* @param self::GT|self::LT $relation | ||
* @param int|float $hoursAgo | ||
*/ | ||
public function __construct(string $relation, $hoursAgo) | ||
{ | ||
$this->relation = $relation; | ||
$this->hoursAgo = $hoursAgo; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'field' => 'first_session', | ||
'relation' => $this->relation, | ||
'hours_ago' => $this->hoursAgo, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OneSignal\Dto\Filter; | ||
|
||
final class LanguageFilter extends AbstractFilter | ||
{ | ||
/** | ||
* @var self::EQ|self::NEQ | ||
*/ | ||
protected string $relation; | ||
|
||
protected string $value; | ||
|
||
/** | ||
* @param self::EQ|self::NEQ $relation | ||
*/ | ||
public function __construct(string $relation, string $value) | ||
{ | ||
$this->relation = $relation; | ||
$this->value = $value; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'field' => 'language', | ||
'relation' => $this->relation, | ||
'value' => $this->value, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OneSignal\Dto\Filter; | ||
|
||
final class LastSessionFilter extends AbstractFilter | ||
{ | ||
/** | ||
* @var self::GT|self::LT | ||
*/ | ||
protected string $relation; | ||
|
||
/** | ||
* @var int|float | ||
*/ | ||
protected $hoursAgo; | ||
|
||
/** | ||
* @param self::GT|self::LT $relation | ||
* @param int|float $hoursAgo | ||
*/ | ||
public function __construct(string $relation, $hoursAgo) | ||
{ | ||
$this->relation = $relation; | ||
$this->hoursAgo = $hoursAgo; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'field' => 'last_session', | ||
'relation' => $this->relation, | ||
'hours_ago' => $this->hoursAgo, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OneSignal\Dto\Filter; | ||
|
||
final class LocationFilter extends AbstractFilter | ||
{ | ||
protected int $radius; | ||
|
||
protected float $lat; | ||
|
||
protected float $long; | ||
|
||
public function __construct(int $radius, float $lat, float $long) | ||
{ | ||
$this->radius = $radius; | ||
$this->lat = $lat; | ||
$this->long = $long; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'field' => 'location', | ||
'radius' => $this->radius, | ||
'lat' => $this->lat, | ||
'long' => $this->long, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OneSignal\Dto\Filter; | ||
|
||
final class SessionCountFilter extends AbstractFilter | ||
{ | ||
/** | ||
* @var self::GT|self::LT|self::EQ|self::NEQ | ||
*/ | ||
protected string $relation; | ||
|
||
protected int $value; | ||
|
||
/** | ||
* @param self::GT|self::LT|self::EQ|self::NEQ $relation | ||
*/ | ||
public function __construct(string $relation, int $value) | ||
{ | ||
$this->relation = $relation; | ||
$this->value = $value; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'field' => 'session_count', | ||
'relation' => $this->relation, | ||
'value' => $this->value, | ||
]; | ||
} | ||
} |
Oops, something went wrong.