Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing segments API calls (v11) #178

Merged
merged 51 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
739bbe5
added segments api calls
rcerljenko Nov 29, 2023
f1b309e
php cs fixer fix
rcerljenko Nov 29, 2023
d37c6bc
moved to phpdoc payload array
rcerljenko Nov 30, 2023
32cde31
fix erros
rcerljenko Nov 30, 2023
21b93b9
fix errors
rcerljenko Nov 30, 2023
7bf3d11
introduce dto
rcerljenko Nov 30, 2023
0ce5531
introduce dto
rcerljenko Nov 30, 2023
87924c6
introduce dto
rcerljenko Nov 30, 2023
bd3440a
fixes
rcerljenko Nov 30, 2023
15ce5cb
removed general purpose pagination dto
rcerljenko Nov 30, 2023
2cbd763
requested changes
rcerljenko Nov 30, 2023
88a9a0d
requested changes
rcerljenko Nov 30, 2023
45ce096
requested changes
rcerljenko Nov 30, 2023
30f411a
requested changes
rcerljenko Nov 30, 2023
310f776
requested changes
rcerljenko Nov 30, 2023
2b73275
requested changes
rcerljenko Nov 30, 2023
59b8b9d
Merge branch 'master' into feature/segments
rcerljenko Nov 30, 2023
ec753de
removed []
rcerljenko Nov 30, 2023
c40dfe9
Merge branch 'feature/segments' of https://github.com/rcerljenko/ones…
rcerljenko Nov 30, 2023
ae0120e
added filters dto
rcerljenko Nov 30, 2023
a9ef92b
added filters dto
rcerljenko Nov 30, 2023
4b00629
added filters dto
rcerljenko Nov 30, 2023
9b52286
fixes
rcerljenko Nov 30, 2023
6285d84
added missing relation key
rcerljenko Dec 1, 2023
177f1a8
moved value to extra params
rcerljenko Dec 1, 2023
95d5307
added relation constants
rcerljenko Dec 1, 2023
19a01fc
introduce separate dtos for every filter type
rcerljenko Dec 1, 2023
079542e
renamed filters
rcerljenko Dec 1, 2023
d039ac9
change request
rcerljenko Dec 4, 2023
171a390
change request
rcerljenko Dec 4, 2023
22b53da
namespace change to singular
rcerljenko Dec 4, 2023
e3c5be8
namespace change to singular
rcerljenko Dec 4, 2023
4e8157f
move operands to abstract class
rcerljenko Dec 4, 2023
7dec6e5
null check filters
rcerljenko Dec 4, 2023
4b26aaf
fix
rcerljenko Dec 4, 2023
72c928e
added response objects
rcerljenko Dec 5, 2023
71ba641
added response objects
rcerljenko Dec 5, 2023
9abc5e3
added exception handling
rcerljenko Dec 5, 2023
3f75b40
added exception handling
rcerljenko Dec 5, 2023
ec9ad0d
added exception handling
rcerljenko Dec 5, 2023
e0587b5
added request and response to exception
rcerljenko Dec 5, 2023
5fb5974
added request and response to exception - fixes
rcerljenko Dec 5, 2023
2a91971
added separate makeRequest method
rcerljenko Dec 5, 2023
3566e53
added separate makeRequest method
rcerljenko Dec 5, 2023
e67cd5d
added separate makeRequest method
rcerljenko Dec 5, 2023
c721474
added separate makeRequest method
rcerljenko Dec 5, 2023
2337167
added list and delete segments tests
rcerljenko Dec 8, 2023
1d81fca
added requested changes
rcerljenko Dec 8, 2023
4d5caf6
removed unused method
rcerljenko Dec 8, 2023
ccc897d
changes
rcerljenko Dec 8, 2023
0886d6e
added test for create segment
rcerljenko Dec 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Dto/AbstractDto.php
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;
}
18 changes: 18 additions & 0 deletions src/Dto/Filter/AbstractFilter.php
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 = '!=';
}
43 changes: 43 additions & 0 deletions src/Dto/Filter/AmountSpentFilter.php
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 = '=';
rcerljenko marked this conversation as resolved.
Show resolved Hide resolved

/**
* @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,
];
}
}
33 changes: 33 additions & 0 deletions src/Dto/Filter/AppVersionFilter.php
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,
];
}
}
41 changes: 41 additions & 0 deletions src/Dto/Filter/BoughtSkuFilter.php
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,
];
}
}
42 changes: 42 additions & 0 deletions src/Dto/Filter/ConditionalFilter.php
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,
];
}
}
24 changes: 24 additions & 0 deletions src/Dto/Filter/CountryFilter.php
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,
];
}
}
37 changes: 37 additions & 0 deletions src/Dto/Filter/FirstSessionFilter.php
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,
];
}
}
33 changes: 33 additions & 0 deletions src/Dto/Filter/LanguageFilter.php
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,
];
}
}
37 changes: 37 additions & 0 deletions src/Dto/Filter/LastSessionFilter.php
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,
];
}
}
31 changes: 31 additions & 0 deletions src/Dto/Filter/LocationFilter.php
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,
];
}
}
33 changes: 33 additions & 0 deletions src/Dto/Filter/SessionCountFilter.php
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,
];
}
}
Loading
Loading