| Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
| GET | /articles/payments | Query payment logs | Query payment logs |
|---|
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QueryBase:
skip: Optional[int] = None
"""
Skip over a given number of elements in a sequence and then return the remainder. Use this when you need paging.<br/><br/><strong>Example:</strong><br/><code>?skip=10&orderBy=Id</code>
"""
take: Optional[int] = None
"""
Return a given number of elements in a sequence and then skip over the remainder. Use this when you need paging.<br/><br/><strong>Example:</strong><br/><code>?take=20</code>
"""
order_by: Optional[str] = None
"""
Comma separated list of fields to order by. Prefix the field name with a minus if you wan't to invert the sort for that field.<br/><br/><strong>Example:</strong><br/><code>?orderBy=Id,-Age,FirstName</code>
"""
order_by_desc: Optional[str] = None
"""
Comma separated list of fields to order by in descending order. Prefix the field name with a minus if you wan't to invert the sort for that field.<br/><br/><strong>Example:</strong><br/><code>?orderByDesc=Id,-Age,FirstName</code>
"""
include: Optional[str] = None
"""
Include any of the aggregates <code>AVG, COUNT, FIRST, LAST, MAX, MIN, SUM</code> in your result set. The results will be returned in the meta field.<br/><br/><strong>Example:</strong><br/><code>?include=COUNT(*) as Total</code><br/><br/>or multiple fields with<br/><code>?include=Count(*) Total, Min(Age), AVG(Age) AverageAge</code><br/></br>or unique with<br/><code>?include=COUNT(DISTINCT LivingStatus) as UniqueStatus</code>
"""
fields: Optional[str] = None
meta: Optional[Dict[str, str]] = None
From = TypeVar('From')
Into = TypeVar('Into')
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QueryDb2(Generic[From, Into], QueryBase, IReturn[QueryResponse[Into]]):
@staticmethod
def response_type(): return QueryResponse[Into]
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BaseModel:
pass
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ArticleType(BaseModel):
article_type_id: int = 0
# @Required()
article_type_name: Optional[str] = None
article_type_description: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CurrencyInfoResponse:
# @ApiMember(Description="The currency id")
id: Optional[str] = None
"""
The currency id
"""
# @ApiMember(Description="The currency id")
name: Optional[str] = None
"""
The currency id
"""
# @ApiMember(Description="The currency id")
currency_sign: Optional[str] = None
"""
The currency id
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PaymentLogQueryResponse:
# @ApiMember(Description="The payment log id")
id: int = 0
"""
The payment log id
"""
# @ApiMember(Description="The internal reference id, could be reference to a booking, rebate code, gift card etc.")
internal_reference: int = 0
"""
The internal reference id, could be reference to a booking, rebate code, gift card etc.
"""
# @ApiMember(Description="The payment reference id")
payment_reference_id: Optional[str] = None
"""
The payment reference id
"""
# @ApiMember(Description="The payment order item reference id")
order_item_reference_id: Optional[str] = None
"""
The payment order item reference id
"""
# @ApiMember(Description="The payment reference id")
payment_provider_id: Optional[int] = None
"""
The payment reference id
"""
# @ApiMember(Description="The payment amount")
amount: float = 0.0
"""
The payment amount
"""
# @ApiMember(Description="The article type")
article_type: Optional[ArticleType] = None
"""
The article type
"""
# @ApiMember(Description="The payment VAT in percent")
vat: Decimal = decimal.Decimal(0)
"""
The payment VAT in percent
"""
# @ApiMember(Description="The payment amount that is credited")
amount_credited: float = 0.0
"""
The payment amount that is credited
"""
# @ApiMember(Description="The payment currency id")
currency_id: Optional[str] = None
"""
The payment currency id
"""
# @ApiMember(Description="The payment currency info")
currency_info: Optional[CurrencyInfoResponse] = None
"""
The payment currency info
"""
# @ApiMember(Description="Comments that could be added to the event log item")
comments: Optional[str] = None
"""
Comments that could be added to the event log item
"""
# @ApiMember(Description="The date when the payment items was created")
created: datetime.datetime = datetime.datetime(1, 1, 1)
"""
The date when the payment items was created
"""
# @ApiMember(Description="The date when the payment items were updated.")
updated: datetime.datetime = datetime.datetime(1, 1, 1)
"""
The date when the payment items were updated.
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Currency(BaseModel):
# @Required()
name: Optional[str] = None
# @Required()
currency_sign: Optional[str] = None
# @Required()
active: bool = False
modified_date: Optional[datetime.datetime] = None
# @Required()
id: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PaymentLog(BaseModel):
# @References(typeof(Currency))
currency_id: Optional[str] = None
currency_info: Optional[Currency] = None
# @Required()
company_id: Optional[str] = None
id: int = 0
# @Required()
internal_reference_id: Optional[str] = None
# @Required()
article_type_id: int = 0
payment_reference_id: Optional[str] = None
payment_provider_id: Optional[int] = None
order_item_reference_id: Optional[str] = None
amount: Optional[float] = None
vat: Optional[Decimal] = None
amount_credited: Optional[float] = None
comments: Optional[str] = None
# @Required()
created: datetime.datetime = datetime.datetime(1, 1, 1)
# @Required()
updated: datetime.datetime = datetime.datetime(1, 1, 1)
modified_date: Optional[datetime.datetime] = None
# @ValidateRequest(Validator="IsAuthenticated")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PaymentLogQuery(QueryDb2[PaymentLog, PaymentLogQueryResponse], ICompany):
# @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
company_id: Optional[str] = None
"""
The company id, if empty will use the company id for the user you are logged in with.
"""
# @ApiMember(DataType="dateTime", Description="Start of interval to query for payments when they where created. UTC+0 and parameter as defined by date-time - RFC3339", ParameterType="query")
created_from: Optional[datetime.datetime] = None
"""
Start of interval to query for payments when they where created. UTC+0 and parameter as defined by date-time - RFC3339
"""
# @ApiMember(DataType="dateTime", Description="End of interval to query for payments when they where created. UTC+0 and parameter as defined by date-time - RFC3339", ParameterType="query")
created_to: Optional[datetime.datetime] = None
"""
End of interval to query for payments when they where created. UTC+0 and parameter as defined by date-time - RFC3339
"""
# @ApiMember(Description="Article type (Could be Service, rebate code types, etc..", IsRequired=true)
article_type_id: Optional[int] = None
"""
Article type (Could be Service, rebate code types, etc..
"""
# @ApiMember(Description="")
include_article_type: bool = False
"""
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AccessKeyTypeResponse:
id: int = 0
key_type: Optional[str] = None
description: Optional[str] = None
T = TypeVar('T')
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QueryResponse(Generic[T]):
offset: int = 0
total: int = 0
results: Optional[List[AccessKeyTypeResponse]] = None
meta: Optional[Dict[str, str]] = None
response_status: Optional[ResponseStatus] = None
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.
GET /articles/payments HTTP/1.1 Host: api.bokamera.se Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
Offset: 0,
Total: 0,
Results:
[
{
Id: 0,
InternalReference: 0,
PaymentReferenceId: String,
OrderItemReferenceId: String,
PaymentProviderId: 0,
Amount: 0,
ArticleType:
{
ArticleTypeId: 0,
ArticleTypeName: String,
ArticleTypeDescription: String
},
VAT: 0,
AmountCredited: 0,
CurrencyId: String,
CurrencyInfo:
{
Id: String,
Name: String,
CurrencySign: String
},
Comments: String
}
],
Meta:
{
String: String
},
ResponseStatus:
{
ErrorCode: String,
Message: String,
StackTrace: String,
Errors:
[
{
ErrorCode: String,
FieldName: String,
Message: String,
Meta:
{
String: String
}
}
],
Meta:
{
String: String
}
}
}