BokaMera.API.Host

<back to all web services

CreateCustomerArticle

Requires Authentication
The following routes are available for this service:
POST/customerarticleCreate a new CustomerArticle.Create a new CustomerArticle directly with price, status, and customer.
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 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)
    duration: int = 0
    services: List[ArticleServiceRelation] = field(default_factory=list)
    service_ids: List[int] = field(default_factory=list)
    price_sign: Optional[str] = None
    vat: Optional[Decimal] = None
    valid_days: int = 0
    send_notification: bool = False
    notification_email: Optional[str] = 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


class CustomerArticleStatusEnum(IntEnum):
    AWAITING_PAYMENT = 1
    AWAITING_PAYMENT_FROM_PROVIDER = 2
    AWAITING_PAYMENT_NO_TIME_LIMIT = 3
    ACTIVE = 4
    OFF = 5


# @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
# @ValidateRequest(Validator="IsAuthenticated")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateCustomerArticle(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(Description="The article id to base this customer article on", IsRequired=true)
    article_id: int = 0
    """
    The article id to base this customer article on
    """


    # @ApiMember(Description="The customer id to assign the article to", IsRequired=true)
    customer_id: Optional[str] = None
    """
    The customer id to assign the article to
    """


    # @ApiMember(Description="The status of the customer article")
    status_id: Optional[CustomerArticleStatusEnum] = None
    """
    The status of the customer article
    """


    # @ApiMember(Description="Optional price override. If not provided, uses the article price.")
    price: Optional[Decimal] = None
    """
    Optional price override. If not provided, uses the article price.
    """


    # @ApiMember(Description="Optional VAT override. If not provided, uses the article VAT.")
    vat: Optional[Decimal] = None
    """
    Optional VAT override. If not provided, uses the article VAT.
    """


    # @ApiMember(Description="Optional currency override. If not provided, uses the article currency.")
    currency_id: Optional[str] = None
    """
    Optional currency override. If not provided, uses the article currency.
    """

Python CreateCustomerArticle DTOs

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

HTTP + OTHER

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

POST /customerarticle HTTP/1.1 
Host: api.bokamera.se 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"CompanyId":"00000000-0000-0000-0000-000000000000","ArticleId":0,"StatusId":"0","Price":0,"VAT":0,"CurrencyId":"String"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
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"}}}