Trendsic Platform Service

<back to all web services

LedgerRequest

Requires Authentication
Requires any of the roles:Agent, Administrator, Agent, Administrator, Agent, Administrator, Agent, Administrator
The following routes are available for this service:
GET,OPTIONS/v1/Ledger/{LedgerId}
GET,POST,OPTIONS/v1/Ledger
<?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 Ledger implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $LedgerId=0,
        /** @var int */
        public int $AgentId=0,
        /** @var int */
        public int $CommissionBatchId=0,
        /** @var string|null */
        public ?string $Rank=null,
        /** @var float */
        public float $Commissions=0.0,
        /** @var float */
        public float $Clawbacks=0.0,
        /** @var float */
        public float $Adjustments=0.0,
        /** @var float */
        public float $PreviousBalance=0.0,
        /** @var float */
        public float $ASAPCharges=0.0,
        /** @var float */
        public float $Payout=0.0,
        /** @var float */
        public float $BalanceForward=0.0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['LedgerId'])) $this->LedgerId = $o['LedgerId'];
        if (isset($o['AgentId'])) $this->AgentId = $o['AgentId'];
        if (isset($o['CommissionBatchId'])) $this->CommissionBatchId = $o['CommissionBatchId'];
        if (isset($o['Rank'])) $this->Rank = $o['Rank'];
        if (isset($o['Commissions'])) $this->Commissions = $o['Commissions'];
        if (isset($o['Clawbacks'])) $this->Clawbacks = $o['Clawbacks'];
        if (isset($o['Adjustments'])) $this->Adjustments = $o['Adjustments'];
        if (isset($o['PreviousBalance'])) $this->PreviousBalance = $o['PreviousBalance'];
        if (isset($o['ASAPCharges'])) $this->ASAPCharges = $o['ASAPCharges'];
        if (isset($o['Payout'])) $this->Payout = $o['Payout'];
        if (isset($o['BalanceForward'])) $this->BalanceForward = $o['BalanceForward'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->LedgerId)) $o['LedgerId'] = $this->LedgerId;
        if (isset($this->AgentId)) $o['AgentId'] = $this->AgentId;
        if (isset($this->CommissionBatchId)) $o['CommissionBatchId'] = $this->CommissionBatchId;
        if (isset($this->Rank)) $o['Rank'] = $this->Rank;
        if (isset($this->Commissions)) $o['Commissions'] = $this->Commissions;
        if (isset($this->Clawbacks)) $o['Clawbacks'] = $this->Clawbacks;
        if (isset($this->Adjustments)) $o['Adjustments'] = $this->Adjustments;
        if (isset($this->PreviousBalance)) $o['PreviousBalance'] = $this->PreviousBalance;
        if (isset($this->ASAPCharges)) $o['ASAPCharges'] = $this->ASAPCharges;
        if (isset($this->Payout)) $o['Payout'] = $this->Payout;
        if (isset($this->BalanceForward)) $o['BalanceForward'] = $this->BalanceForward;
        return empty($o) ? new class(){} : $o;
    }
}

class LedgerExtended extends Ledger implements JsonSerializable
{
    /**
     * @param int $LedgerId
     * @param int $AgentId
     * @param int $CommissionBatchId
     * @param string|null $Rank
     * @param float $Commissions
     * @param float $Clawbacks
     * @param float $Adjustments
     * @param float $PreviousBalance
     * @param float $ASAPCharges
     * @param float $Payout
     * @param float $BalanceForward
     */
    public function __construct(
        int $LedgerId=0,
        int $AgentId=0,
        int $CommissionBatchId=0,
        ?string $Rank=null,
        float $Commissions=0.0,
        float $Clawbacks=0.0,
        float $Adjustments=0.0,
        float $PreviousBalance=0.0,
        float $ASAPCharges=0.0,
        float $Payout=0.0,
        float $BalanceForward=0.0,
        /** @var string|null */
        public ?string $AgentFirstName=null,
        /** @var string|null */
        public ?string $AgentLastName=null,
        /** @var string|null */
        public ?string $AgentName=null,
        /** @var float */
        public float $AgentLevel=0.0,
        /** @var string|null */
        public ?string $PayChexId=null
    ) {
        parent::__construct($LedgerId,$AgentId,$CommissionBatchId,$Rank,$Commissions,$Clawbacks,$Adjustments,$PreviousBalance,$ASAPCharges,$Payout,$BalanceForward);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['AgentFirstName'])) $this->AgentFirstName = $o['AgentFirstName'];
        if (isset($o['AgentLastName'])) $this->AgentLastName = $o['AgentLastName'];
        if (isset($o['AgentName'])) $this->AgentName = $o['AgentName'];
        if (isset($o['AgentLevel'])) $this->AgentLevel = $o['AgentLevel'];
        if (isset($o['PayChexId'])) $this->PayChexId = $o['PayChexId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->AgentFirstName)) $o['AgentFirstName'] = $this->AgentFirstName;
        if (isset($this->AgentLastName)) $o['AgentLastName'] = $this->AgentLastName;
        if (isset($this->AgentName)) $o['AgentName'] = $this->AgentName;
        if (isset($this->AgentLevel)) $o['AgentLevel'] = $this->AgentLevel;
        if (isset($this->PayChexId)) $o['PayChexId'] = $this->PayChexId;
        return empty($o) ? new class(){} : $o;
    }
}

class LedgerResponse implements JsonSerializable
{
    public function __construct(
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null,
        /** @var array<LedgerExtended>|null */
        public ?array $Ledger=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
        if (isset($o['Ledger'])) $this->Ledger = JsonConverters::fromArray('LedgerExtended', $o['Ledger']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
        if (isset($this->Ledger)) $o['Ledger'] = JsonConverters::toArray('LedgerExtended', $this->Ledger);
        return empty($o) ? new class(){} : $o;
    }
}

class LedgerRequest implements JsonSerializable
{
    public function __construct(
        /** @var array<LedgerExtended>|null */
        public ?array $Ledger=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Ledger'])) $this->Ledger = JsonConverters::fromArray('LedgerExtended', $o['Ledger']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Ledger)) $o['Ledger'] = JsonConverters::toArray('LedgerExtended', $this->Ledger);
        return empty($o) ? new class(){} : $o;
    }
}

PHP LedgerRequest DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml

HTTP + XML

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /v1/Ledger HTTP/1.1 
Host: api.dev.dynamics.trendsic.com 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<LedgerRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
  <Ledger>
    <LedgerExtended>
      <ASAPCharges>0</ASAPCharges>
      <Adjustments>0</Adjustments>
      <AgentId>0</AgentId>
      <BalanceForward>0</BalanceForward>
      <Clawbacks>0</Clawbacks>
      <CommissionBatchId>0</CommissionBatchId>
      <Commissions>0</Commissions>
      <LedgerId>0</LedgerId>
      <Payout>0</Payout>
      <PreviousBalance>0</PreviousBalance>
      <Rank>String</Rank>
      <AgentFirstName>String</AgentFirstName>
      <AgentLastName>String</AgentLastName>
      <AgentLevel>0</AgentLevel>
      <AgentName>String</AgentName>
      <PayChexId>String</PayChexId>
    </LedgerExtended>
  </Ledger>
</LedgerRequest>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<LedgerResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
  <Ledger>
    <LedgerExtended>
      <ASAPCharges>0</ASAPCharges>
      <Adjustments>0</Adjustments>
      <AgentId>0</AgentId>
      <BalanceForward>0</BalanceForward>
      <Clawbacks>0</Clawbacks>
      <CommissionBatchId>0</CommissionBatchId>
      <Commissions>0</Commissions>
      <LedgerId>0</LedgerId>
      <Payout>0</Payout>
      <PreviousBalance>0</PreviousBalance>
      <Rank>String</Rank>
      <AgentFirstName>String</AgentFirstName>
      <AgentLastName>String</AgentLastName>
      <AgentLevel>0</AgentLevel>
      <AgentName>String</AgentName>
      <PayChexId>String</PayChexId>
    </LedgerExtended>
  </Ledger>
  <ResponseStatus xmlns:d2p1="http://schemas.servicestack.net/types">
    <d2p1:ErrorCode>String</d2p1:ErrorCode>
    <d2p1:Message>String</d2p1:Message>
    <d2p1:StackTrace>String</d2p1:StackTrace>
    <d2p1:Errors>
      <d2p1:ResponseError>
        <d2p1:ErrorCode>String</d2p1:ErrorCode>
        <d2p1:FieldName>String</d2p1:FieldName>
        <d2p1:Message>String</d2p1:Message>
        <d2p1:Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:KeyValueOfstringstring>
            <d5p1:Key>String</d5p1:Key>
            <d5p1:Value>String</d5p1:Value>
          </d5p1:KeyValueOfstringstring>
        </d2p1:Meta>
      </d2p1:ResponseError>
    </d2p1:Errors>
    <d2p1:Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:KeyValueOfstringstring>
        <d3p1:Key>String</d3p1:Key>
        <d3p1:Value>String</d3p1:Value>
      </d3p1:KeyValueOfstringstring>
    </d2p1:Meta>
  </ResponseStatus>
</LedgerResponse>