| PUT | /customerarticle/{Id} | Update an existing CustomerArticle. | Update an existing CustomerArticle. |
|---|
<?php namespace dtos;
use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};
class BaseModel implements JsonSerializable
{
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
return empty($o) ? new class(){} : $o;
}
}
class ArticleServiceRelation extends BaseModel implements JsonSerializable
{
public function __construct(
// @Required()
/** @var string */
public string $CompanyId='',
/** @var int */
public int $Id=0,
// @Required()
/** @var int */
public int $ServiceId=0,
// @Required()
/** @var int */
public int $ArticleId=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['ServiceId'])) $this->ServiceId = $o['ServiceId'];
if (isset($o['ArticleId'])) $this->ArticleId = $o['ArticleId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->ServiceId)) $o['ServiceId'] = $this->ServiceId;
if (isset($this->ArticleId)) $o['ArticleId'] = $this->ArticleId;
return empty($o) ? new class(){} : $o;
}
}
class ArticleResponse implements JsonSerializable
{
public function __construct(
/** @var string */
public string $CompanyId='',
/** @var int */
public int $Id=0,
/** @var string */
public string $Name='',
/** @var int */
public int $ArticleTypeId=0,
/** @var string */
public string $Description='',
/** @var string */
public string $ImageUrl='',
/** @var bool|null */
public ?bool $Active=null,
/** @var int */
public int $Amount=0,
/** @var float */
public float $Price=0.0,
/** @var string */
public string $CurrencyId='',
/** @var int */
public int $SortOrder=0,
/** @var DateTime */
public DateTime $UpdatedDate=new DateTime(),
/** @var DateTime */
public DateTime $CreatedDate=new DateTime(),
/** @var int */
public int $Duration=0,
/** @var array<ArticleServiceRelation>|null */
public ?array $Services=null,
/** @var array<int>|null */
public ?array $ServiceIds=null,
/** @var string */
public string $PriceSign='',
/** @var float|null */
public ?float $VAT=null,
/** @var int */
public int $ValidDays=0,
/** @var bool|null */
public ?bool $SendNotification=null,
/** @var string */
public string $NotificationEmail=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['Name'])) $this->Name = $o['Name'];
if (isset($o['ArticleTypeId'])) $this->ArticleTypeId = $o['ArticleTypeId'];
if (isset($o['Description'])) $this->Description = $o['Description'];
if (isset($o['ImageUrl'])) $this->ImageUrl = $o['ImageUrl'];
if (isset($o['Active'])) $this->Active = $o['Active'];
if (isset($o['Amount'])) $this->Amount = $o['Amount'];
if (isset($o['Price'])) $this->Price = $o['Price'];
if (isset($o['CurrencyId'])) $this->CurrencyId = $o['CurrencyId'];
if (isset($o['SortOrder'])) $this->SortOrder = $o['SortOrder'];
if (isset($o['UpdatedDate'])) $this->UpdatedDate = JsonConverters::from('DateTime', $o['UpdatedDate']);
if (isset($o['CreatedDate'])) $this->CreatedDate = JsonConverters::from('DateTime', $o['CreatedDate']);
if (isset($o['Duration'])) $this->Duration = $o['Duration'];
if (isset($o['Services'])) $this->Services = JsonConverters::fromArray('ArticleServiceRelation', $o['Services']);
if (isset($o['ServiceIds'])) $this->ServiceIds = JsonConverters::fromArray('int', $o['ServiceIds']);
if (isset($o['PriceSign'])) $this->PriceSign = $o['PriceSign'];
if (isset($o['VAT'])) $this->VAT = $o['VAT'];
if (isset($o['ValidDays'])) $this->ValidDays = $o['ValidDays'];
if (isset($o['SendNotification'])) $this->SendNotification = $o['SendNotification'];
if (isset($o['NotificationEmail'])) $this->NotificationEmail = $o['NotificationEmail'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->Name)) $o['Name'] = $this->Name;
if (isset($this->ArticleTypeId)) $o['ArticleTypeId'] = $this->ArticleTypeId;
if (isset($this->Description)) $o['Description'] = $this->Description;
if (isset($this->ImageUrl)) $o['ImageUrl'] = $this->ImageUrl;
if (isset($this->Active)) $o['Active'] = $this->Active;
if (isset($this->Amount)) $o['Amount'] = $this->Amount;
if (isset($this->Price)) $o['Price'] = $this->Price;
if (isset($this->CurrencyId)) $o['CurrencyId'] = $this->CurrencyId;
if (isset($this->SortOrder)) $o['SortOrder'] = $this->SortOrder;
if (isset($this->UpdatedDate)) $o['UpdatedDate'] = JsonConverters::to('DateTime', $this->UpdatedDate);
if (isset($this->CreatedDate)) $o['CreatedDate'] = JsonConverters::to('DateTime', $this->CreatedDate);
if (isset($this->Duration)) $o['Duration'] = $this->Duration;
if (isset($this->Services)) $o['Services'] = JsonConverters::toArray('ArticleServiceRelation', $this->Services);
if (isset($this->ServiceIds)) $o['ServiceIds'] = JsonConverters::toArray('int', $this->ServiceIds);
if (isset($this->PriceSign)) $o['PriceSign'] = $this->PriceSign;
if (isset($this->VAT)) $o['VAT'] = $this->VAT;
if (isset($this->ValidDays)) $o['ValidDays'] = $this->ValidDays;
if (isset($this->SendNotification)) $o['SendNotification'] = $this->SendNotification;
if (isset($this->NotificationEmail)) $o['NotificationEmail'] = $this->NotificationEmail;
return empty($o) ? new class(){} : $o;
}
}
class CustomerArticleCustomerResponse implements JsonSerializable
{
public function __construct(
/** @var string */
public string $Id='',
/** @var string */
public string $Firstname='',
/** @var string */
public string $Lastname='',
/** @var string */
public string $Email='',
/** @var string */
public string $Phone=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['Firstname'])) $this->Firstname = $o['Firstname'];
if (isset($o['Lastname'])) $this->Lastname = $o['Lastname'];
if (isset($o['Email'])) $this->Email = $o['Email'];
if (isset($o['Phone'])) $this->Phone = $o['Phone'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->Firstname)) $o['Firstname'] = $this->Firstname;
if (isset($this->Lastname)) $o['Lastname'] = $this->Lastname;
if (isset($this->Email)) $o['Email'] = $this->Email;
if (isset($this->Phone)) $o['Phone'] = $this->Phone;
return empty($o) ? new class(){} : $o;
}
}
class CustomerArticleCompanyResponse implements JsonSerializable
{
public function __construct(
/** @var string */
public string $Id='',
/** @var string */
public string $Name='',
/** @var string */
public string $LogoType='',
/** @var string */
public string $Email='',
/** @var string */
public string $Phone='',
/** @var string */
public string $City='',
/** @var string */
public string $Street1='',
/** @var string */
public string $ZipCode='',
/** @var string */
public string $CountryId=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['Name'])) $this->Name = $o['Name'];
if (isset($o['LogoType'])) $this->LogoType = $o['LogoType'];
if (isset($o['Email'])) $this->Email = $o['Email'];
if (isset($o['Phone'])) $this->Phone = $o['Phone'];
if (isset($o['City'])) $this->City = $o['City'];
if (isset($o['Street1'])) $this->Street1 = $o['Street1'];
if (isset($o['ZipCode'])) $this->ZipCode = $o['ZipCode'];
if (isset($o['CountryId'])) $this->CountryId = $o['CountryId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->Name)) $o['Name'] = $this->Name;
if (isset($this->LogoType)) $o['LogoType'] = $this->LogoType;
if (isset($this->Email)) $o['Email'] = $this->Email;
if (isset($this->Phone)) $o['Phone'] = $this->Phone;
if (isset($this->City)) $o['City'] = $this->City;
if (isset($this->Street1)) $o['Street1'] = $this->Street1;
if (isset($this->ZipCode)) $o['ZipCode'] = $this->ZipCode;
if (isset($this->CountryId)) $o['CountryId'] = $this->CountryId;
return empty($o) ? new class(){} : $o;
}
}
class PaymentLogResponse implements JsonSerializable
{
public function __construct(
/** @var int */
public int $Id=0,
/** @var float|null */
public ?float $Amount=null,
/** @var float|null */
public ?float $AmountCredited=null,
/** @var string */
public string $CurrencyId='',
/** @var string */
public string $Comments='',
/** @var DateTime */
public DateTime $Created=new DateTime(),
/** @var DateTime */
public DateTime $Updated=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['Amount'])) $this->Amount = $o['Amount'];
if (isset($o['AmountCredited'])) $this->AmountCredited = $o['AmountCredited'];
if (isset($o['CurrencyId'])) $this->CurrencyId = $o['CurrencyId'];
if (isset($o['Comments'])) $this->Comments = $o['Comments'];
if (isset($o['Created'])) $this->Created = JsonConverters::from('DateTime', $o['Created']);
if (isset($o['Updated'])) $this->Updated = JsonConverters::from('DateTime', $o['Updated']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->Amount)) $o['Amount'] = $this->Amount;
if (isset($this->AmountCredited)) $o['AmountCredited'] = $this->AmountCredited;
if (isset($this->CurrencyId)) $o['CurrencyId'] = $this->CurrencyId;
if (isset($this->Comments)) $o['Comments'] = $this->Comments;
if (isset($this->Created)) $o['Created'] = JsonConverters::to('DateTime', $this->Created);
if (isset($this->Updated)) $o['Updated'] = JsonConverters::to('DateTime', $this->Updated);
return empty($o) ? new class(){} : $o;
}
}
class CustomerArticleResponse implements JsonSerializable
{
public function __construct(
/** @var int */
public int $Id=0,
/** @var string */
public string $CompanyId='',
/** @var int|null */
public ?int $ArticleId=null,
/** @var float|null */
public ?float $Price=null,
/** @var float|null */
public ?float $VAT=null,
/** @var string */
public string $CurrencyId='',
/** @var int */
public int $StatusId=0,
/** @var string */
public string $StatusName='',
/** @var string|null */
public ?string $CustomerId=null,
/** @var DateTime */
public DateTime $CreatedDate=new DateTime(),
/** @var DateTime */
public DateTime $UpdatedDate=new DateTime(),
/** @var ArticleResponse|null */
public ?ArticleResponse $Article=null,
/** @var CustomerArticleCustomerResponse|null */
public ?CustomerArticleCustomerResponse $Customer=null,
/** @var CustomerArticleCompanyResponse|null */
public ?CustomerArticleCompanyResponse $Company=null,
/** @var array<PaymentLogResponse>|null */
public ?array $PaymentLog=null,
/** @var ResponseStatus|null */
public ?ResponseStatus $ResponseStatus=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['ArticleId'])) $this->ArticleId = $o['ArticleId'];
if (isset($o['Price'])) $this->Price = $o['Price'];
if (isset($o['VAT'])) $this->VAT = $o['VAT'];
if (isset($o['CurrencyId'])) $this->CurrencyId = $o['CurrencyId'];
if (isset($o['StatusId'])) $this->StatusId = $o['StatusId'];
if (isset($o['StatusName'])) $this->StatusName = $o['StatusName'];
if (isset($o['CustomerId'])) $this->CustomerId = $o['CustomerId'];
if (isset($o['CreatedDate'])) $this->CreatedDate = JsonConverters::from('DateTime', $o['CreatedDate']);
if (isset($o['UpdatedDate'])) $this->UpdatedDate = JsonConverters::from('DateTime', $o['UpdatedDate']);
if (isset($o['Article'])) $this->Article = JsonConverters::from('ArticleResponse', $o['Article']);
if (isset($o['Customer'])) $this->Customer = JsonConverters::from('CustomerArticleCustomerResponse', $o['Customer']);
if (isset($o['Company'])) $this->Company = JsonConverters::from('CustomerArticleCompanyResponse', $o['Company']);
if (isset($o['PaymentLog'])) $this->PaymentLog = JsonConverters::fromArray('PaymentLogResponse', $o['PaymentLog']);
if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->ArticleId)) $o['ArticleId'] = $this->ArticleId;
if (isset($this->Price)) $o['Price'] = $this->Price;
if (isset($this->VAT)) $o['VAT'] = $this->VAT;
if (isset($this->CurrencyId)) $o['CurrencyId'] = $this->CurrencyId;
if (isset($this->StatusId)) $o['StatusId'] = $this->StatusId;
if (isset($this->StatusName)) $o['StatusName'] = $this->StatusName;
if (isset($this->CustomerId)) $o['CustomerId'] = $this->CustomerId;
if (isset($this->CreatedDate)) $o['CreatedDate'] = JsonConverters::to('DateTime', $this->CreatedDate);
if (isset($this->UpdatedDate)) $o['UpdatedDate'] = JsonConverters::to('DateTime', $this->UpdatedDate);
if (isset($this->Article)) $o['Article'] = JsonConverters::to('ArticleResponse', $this->Article);
if (isset($this->Customer)) $o['Customer'] = JsonConverters::to('CustomerArticleCustomerResponse', $this->Customer);
if (isset($this->Company)) $o['Company'] = JsonConverters::to('CustomerArticleCompanyResponse', $this->Company);
if (isset($this->PaymentLog)) $o['PaymentLog'] = JsonConverters::toArray('PaymentLogResponse', $this->PaymentLog);
if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
return empty($o) ? new class(){} : $o;
}
}
enum CustomerArticleStatusEnum : int
{
case AwaitingPayment = 1;
case AwaitingPaymentFromProvider = 2;
case AwaitingPaymentNoTimeLimit = 3;
case Active = 4;
case Off = 5;
}
// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class UpdateCustomerArticle implements ICompany, JsonSerializable
{
public function __construct(
/** @description The customer article id */
// @ApiMember(Description="The customer article id", IsRequired=true, ParameterType="path")
/** @var int */
public int $Id=0,
/** @description The company id, if empty will use the company id for the user you are logged in with. */
// @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
/** @var string|null */
public ?string $CompanyId=null,
/** @description The new status of the customer article */
// @ApiMember(Description="The new status of the customer article")
/** @var CustomerArticleStatusEnum|null */
public ?CustomerArticleStatusEnum $StatusId=null,
/** @description Updated price */
// @ApiMember(Description="Updated price")
/** @var float|null */
public ?float $Price=null,
/** @description Updated VAT */
// @ApiMember(Description="Updated VAT")
/** @var float|null */
public ?float $VAT=null,
/** @description Updated currency */
// @ApiMember(Description="Updated currency")
/** @var string */
public string $CurrencyId=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['StatusId'])) $this->StatusId = JsonConverters::from('CustomerArticleStatusEnum', $o['StatusId']);
if (isset($o['Price'])) $this->Price = $o['Price'];
if (isset($o['VAT'])) $this->VAT = $o['VAT'];
if (isset($o['CurrencyId'])) $this->CurrencyId = $o['CurrencyId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->StatusId)) $o['StatusId'] = JsonConverters::to('CustomerArticleStatusEnum', $this->StatusId);
if (isset($this->Price)) $o['Price'] = $this->Price;
if (isset($this->VAT)) $o['VAT'] = $this->VAT;
if (isset($this->CurrencyId)) $o['CurrencyId'] = $this->CurrencyId;
return empty($o) ? new class(){} : $o;
}
}
PHP UpdateCustomerArticle DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
PUT /customerarticle/{Id} HTTP/1.1
Host: api.bokamera.se
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
Id: 0,
CompanyId: 00000000-0000-0000-0000-000000000000,
StatusId: 0,
Price: 0,
VAT: 0,
CurrencyId: String
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
Id: 0,
ArticleId: 0,
Price: 0,
VAT: 0,
CurrencyId: String,
StatusId: 0,
StatusName: String,
CustomerId: 00000000-0000-0000-0000-000000000000,
Article:
{
Id: 0,
Name: String,
ArticleTypeId: 0,
Description: String,
ImageUrl: String,
Active: False,
Amount: 0,
Price: 0,
CurrencyId: String,
SortOrder: 0,
Duration: 0,
Services:
[
{
Id: 0,
ServiceId: 0,
ArticleId: 0
}
],
ServiceIds:
[
0
],
PriceSign: String,
VAT: 0,
ValidDays: 0,
SendNotification: False,
NotificationEmail: String
},
Customer:
{
Firstname: String,
Lastname: String,
Email: String,
Phone: String
},
Company:
{
Name: String,
LogoType: String,
Email: String,
Phone: String,
City: String,
Street1: String,
ZipCode: String,
CountryId: String
},
PaymentLog:
[
{
Id: 0,
Amount: 0,
AmountCredited: 0,
CurrencyId: String,
Comments: String
}
],
ResponseStatus:
{
ErrorCode: String,
Message: String,
StackTrace: String,
Errors:
[
{
ErrorCode: String,
FieldName: String,
Message: String,
Meta:
{
String: String
}
}
],
Meta:
{
String: String
}
}
}