| POST | /customerarticle/fromarticle | Create CustomerArticle. | Create CustomerArticle. |
|---|
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
Object = TypeVar('Object')
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomerBase(ICustomerBase):
customer_id: Optional[str] = None
firstname: Optional[str] = None
lastname: Optional[str] = None
email: Optional[str] = None
phone: Optional[str] = None
subscribed_to_newsletter: bool = False
personal_identity_number: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomerToHandle(CustomerBase):
pass
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class InvoiceAddressToHandle(IInvoiceAddress):
corporate_identity_number: Optional[str] = None
invoice_address1: Optional[str] = None
invoice_address2: Optional[str] = None
invoice_city: Optional[str] = None
invoice_postal_code: Optional[str] = None
invoice_country_code: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FromArticleBase:
# @ApiMember(Description="")
company_id: Optional[str] = None
"""
"""
# @ApiMember(Description="Article ID for the rebate code", IsRequired=true)
article_id: int = 0
"""
Article ID for the rebate code
"""
# @ApiMember(Description="Customer information")
customer: Optional[CustomerToHandle] = None
"""
Customer information
"""
# @ApiMember(Description="If you want to book with customer information instead of the Customer Id send the customer information here. Note: If customer profile already exists with the same email the information will not be changed, instead the provided information will be added as BookingsComments if it differs from the ordinairy profile. ")
invoice_address: Optional[InvoiceAddressToHandle] = None
"""
If you want to book with customer information instead of the Customer Id send the customer information here. Note: If customer profile already exists with the same email the information will not be changed, instead the provided information will be added as BookingsComments if it differs from the ordinairy profile.
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BaseModel:
pass
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ArticleServiceRelation(BaseModel):
# @Required()
company_id: Optional[str] = None
id: int = 0
# @Required()
service_id: int = 0
# @Required()
article_id: int = 0
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ArticleResponse:
company_id: Optional[str] = None
id: int = 0
name: Optional[str] = None
article_type_id: int = 0
description: Optional[str] = None
image_url: Optional[str] = None
active: bool = False
amount: int = 0
price: float = 0.0
currency_id: Optional[str] = None
sort_order: int = 0
updated_date: datetime.datetime = datetime.datetime(1, 1, 1)
created_date: datetime.datetime = datetime.datetime(1, 1, 1)
services: List[ArticleServiceRelation] = field(default_factory=list)
service_ids: List[int] = field(default_factory=list)
price_sign: Optional[str] = None
vat: Optional[Decimal] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomerArticleCustomerResponse:
id: Optional[str] = None
firstname: Optional[str] = None
lastname: Optional[str] = None
email: Optional[str] = None
phone: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomerArticleCompanyResponse:
id: Optional[str] = None
name: Optional[str] = None
logo_type: Optional[str] = None
email: Optional[str] = None
phone: Optional[str] = None
city: Optional[str] = None
street1: Optional[str] = None
zip_code: Optional[str] = None
country_id: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PaymentLogResponse:
id: int = 0
amount: Optional[float] = None
amount_credited: Optional[float] = None
currency_id: Optional[str] = None
comments: Optional[str] = None
created: datetime.datetime = datetime.datetime(1, 1, 1)
updated: datetime.datetime = datetime.datetime(1, 1, 1)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomerArticleResponse:
id: int = 0
company_id: Optional[str] = None
article_id: Optional[int] = None
price: Optional[Decimal] = None
vat: Optional[Decimal] = None
currency_id: Optional[str] = None
status_id: int = 0
status_name: Optional[str] = None
customer_id: Optional[str] = None
created_date: datetime.datetime = datetime.datetime(1, 1, 1)
updated_date: datetime.datetime = datetime.datetime(1, 1, 1)
article: Optional[ArticleResponse] = None
customer: Optional[CustomerArticleCustomerResponse] = None
company: Optional[CustomerArticleCompanyResponse] = None
payment_log: List[PaymentLogResponse] = field(default_factory=list)
response_status: Optional[ResponseStatus] = None
# @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateCustomerArticleFromArticle(FromArticleBase, ICompany):
pass
Python CreateCustomerArticleFromArticle DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /customerarticle/fromarticle HTTP/1.1
Host: testapi.bokamera.se
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"CompanyId":"00000000-0000-0000-0000-000000000000","ArticleId":0,"Customer":{"CustomerId":"00000000-0000-0000-0000-000000000000","Firstname":"String","Lastname":"String","Email":"String","Phone":"String","SubscribedToNewsletter":false,"PersonalIdentityNumber":"String"},"InvoiceAddress":{"CorporateIdentityNumber":"String","InvoiceAddress1":"String","InvoiceAddress2":"String","InvoiceCity":"String","InvoicePostalCode":"String","InvoiceCountryCode":"String"}}
HTTP/1.1 200 OK
Content-Type: text/csv
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,"Services":[{"Id":0,"ServiceId":0,"ArticleId":0}],"ServiceIds":[0],"PriceSign":"String","VAT":0},"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"}}}