Skip to content

Commit

Permalink
Domein prijzen updates / M365 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdgeijn committed Jul 12, 2022
1 parent ccdfef7 commit 1edbeec
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Requests/CompanyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function get(string $companyId ): ?Company
*/
public function create(Company $company): ?Company
{
$response = $this->getRequest('/v1/companies', $company->toObject() );
$response = $this->postRequest('/v1/companies', $company->toObject() );

if ($response->getStatusCode() == 200)
return Company::parse(json_decode( $response->getBody() ) );
Expand Down
4 changes: 2 additions & 2 deletions src/Requests/ContactRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public function get(string $companyId, string $contactId ): ?Contact
* @return Contact|null
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function create(Contact $contact): ?Contact
public function create(string $companyId, Contact $contact): ?Contact
{
$response = $this->getRequest('/v1/companies/contacts', $contact->createContact() );
$response = $this->postRequest("/v1/companies/$companyId/contacts", $contact->toObject() );

if ($response->getStatusCode() == 200)
return Contact::parse(json_decode( $response->getBody() ) );
Expand Down
14 changes: 14 additions & 0 deletions src/Responses/AbstractResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ public function toObject(): \stdClass
return $object;
}

/**
* @return \stdClass
*/
public function toArray(): array
{
$array = [];

foreach( $this as $key => $value )
$array[$key] = $value;

return $array;
}


/**
* @param object $item
* @return AbstractResponse
Expand Down
24 changes: 18 additions & 6 deletions src/Responses/ContactType.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,19 @@ public static function getContactTypes(): array
];
}

public function enableAdmin( bool $primary = false )
public function enableAdmin( bool $primary = false ): static
{
$this->types[self::CONTACTTYPE_ADMIN] = $primary;

return $this;
}

public function disableAdmin( )
public function disableAdmin( ): static
{
if( isset( $this->types[self::CONTACTTYPE_ADMIN] ) )
unset( $this->types[self::CONTACTTYPE_ADMIN]);

return $this;
}

public function isAdmin(): bool
Expand All @@ -72,15 +76,19 @@ public function isPrimaryAdmin(): bool
return isset( $this->types[self::CONTACTTYPE_ADMIN] ) && $this->types[self::CONTACTTYPE_ADMIN] == true;
}

public function enableTechnical( bool $primary = false )
public function enableTechnical( bool $primary = false ): static
{
$this->types[self::CONTACTTYPE_TECH] = $primary;

return $this;
}

public function disableTechnical( )
public function disableTechnical( ): static
{
if( isset( $this->types[self::CONTACTTYPE_TECH] ) )
unset( $this->types[self::CONTACTTYPE_TECH]);

return $this;
}

public function isTechnical(): bool
Expand All @@ -93,15 +101,19 @@ public function isPrimaryTechnical(): bool
return isset( $this->types[self::CONTACTTYPE_TECH] ) && $this->types[self::CONTACTTYPE_TECH] == true;
}

public function enableBilling( bool $primary = false )
public function enableBilling( bool $primary = false ): static
{
$this->types[self::CONTACTTYPE_BILLING] = $primary;

return $this;
}

public function disableBilling( )
public function disableBilling( ): static
{
if( isset( $this->types[self::CONTACTTYPE_BILLING] ) )
unset( $this->types[self::CONTACTTYPE_BILLING]);

return $this;
}

public function isBilling(): bool
Expand Down

0 comments on commit 1edbeec

Please sign in to comment.