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 'package:servicestack/servicestack.dart';

class BaseModel implements IConvertible
{
    BaseModel();
    BaseModel.fromJson(Map<String, dynamic> json) : super();
    fromMap(Map<String, dynamic> json) {
        return this;
    }

    Map<String, dynamic> toJson() => {};
    getTypeName() => "BaseModel";
    TypeContext? context = _ctx;
}

class ArticleServiceRelation extends BaseModel implements IConvertible
{
    // @Required()
    String CompanyId = "";

    int Id = 0;
    // @Required()
    int ServiceId = 0;

    // @Required()
    int ArticleId = 0;

    ArticleServiceRelation({this.CompanyId,this.Id,this.ServiceId,this.ArticleId});
    ArticleServiceRelation.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        CompanyId = json['CompanyId'];
        Id = json['Id'];
        ServiceId = json['ServiceId'];
        ArticleId = json['ArticleId'];
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'CompanyId': CompanyId,
        'Id': Id,
        'ServiceId': ServiceId,
        'ArticleId': ArticleId
    });

    getTypeName() => "ArticleServiceRelation";
    TypeContext? context = _ctx;
}

class ArticleResponse implements IConvertible
{
    String CompanyId = "";
    int Id = 0;
    String Name = "";
    int ArticleTypeId = 0;
    String Description = "";
    String ImageUrl = "";
    bool Active;
    int Amount = 0;
    double Price = 0;
    String CurrencyId = "";
    int SortOrder = 0;
    DateTime UpdatedDate = DateTime(0);
    DateTime CreatedDate = DateTime(0);
    int Duration = 0;
    List<ArticleServiceRelation> Services = [];
    List<int> ServiceIds = [];
    String PriceSign = "";
    double? VAT;
    int ValidDays = 0;
    bool SendNotification;
    String NotificationEmail = "";

    ArticleResponse({this.CompanyId,this.Id,this.Name,this.ArticleTypeId,this.Description,this.ImageUrl,this.Active,this.Amount,this.Price,this.CurrencyId,this.SortOrder,this.UpdatedDate,this.CreatedDate,this.Duration,this.Services,this.ServiceIds,this.PriceSign,this.VAT,this.ValidDays,this.SendNotification,this.NotificationEmail});
    ArticleResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        CompanyId = json['CompanyId'];
        Id = json['Id'];
        Name = json['Name'];
        ArticleTypeId = json['ArticleTypeId'];
        Description = json['Description'];
        ImageUrl = json['ImageUrl'];
        Active = json['Active'];
        Amount = json['Amount'];
        Price = JsonConverters.toDouble(json['Price']);
        CurrencyId = json['CurrencyId'];
        SortOrder = json['SortOrder'];
        UpdatedDate = JsonConverters.fromJson(json['UpdatedDate'],'DateTime',context!);
        CreatedDate = JsonConverters.fromJson(json['CreatedDate'],'DateTime',context!);
        Duration = json['Duration'];
        Services = JsonConverters.fromJson(json['Services'],'List<ArticleServiceRelation>',context!);
        ServiceIds = JsonConverters.fromJson(json['ServiceIds'],'List<int>',context!);
        PriceSign = json['PriceSign'];
        VAT = JsonConverters.toDouble(json['VAT']);
        ValidDays = json['ValidDays'];
        SendNotification = json['SendNotification'];
        NotificationEmail = json['NotificationEmail'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'CompanyId': CompanyId,
        'Id': Id,
        'Name': Name,
        'ArticleTypeId': ArticleTypeId,
        'Description': Description,
        'ImageUrl': ImageUrl,
        'Active': Active,
        'Amount': Amount,
        'Price': Price,
        'CurrencyId': CurrencyId,
        'SortOrder': SortOrder,
        'UpdatedDate': JsonConverters.toJson(UpdatedDate,'DateTime',context!),
        'CreatedDate': JsonConverters.toJson(CreatedDate,'DateTime',context!),
        'Duration': Duration,
        'Services': JsonConverters.toJson(Services,'List<ArticleServiceRelation>',context!),
        'ServiceIds': JsonConverters.toJson(ServiceIds,'List<int>',context!),
        'PriceSign': PriceSign,
        'VAT': VAT,
        'ValidDays': ValidDays,
        'SendNotification': SendNotification,
        'NotificationEmail': NotificationEmail
    };

    getTypeName() => "ArticleResponse";
    TypeContext? context = _ctx;
}

class CustomerArticleCustomerResponse implements IConvertible
{
    String Id = "";
    String Firstname = "";
    String Lastname = "";
    String Email = "";
    String Phone = "";

    CustomerArticleCustomerResponse({this.Id,this.Firstname,this.Lastname,this.Email,this.Phone});
    CustomerArticleCustomerResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Id = json['Id'];
        Firstname = json['Firstname'];
        Lastname = json['Lastname'];
        Email = json['Email'];
        Phone = json['Phone'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Id': Id,
        'Firstname': Firstname,
        'Lastname': Lastname,
        'Email': Email,
        'Phone': Phone
    };

    getTypeName() => "CustomerArticleCustomerResponse";
    TypeContext? context = _ctx;
}

class CustomerArticleCompanyResponse implements IConvertible
{
    String Id = "";
    String Name = "";
    String LogoType = "";
    String Email = "";
    String Phone = "";
    String City = "";
    String Street1 = "";
    String ZipCode = "";
    String CountryId = "";

    CustomerArticleCompanyResponse({this.Id,this.Name,this.LogoType,this.Email,this.Phone,this.City,this.Street1,this.ZipCode,this.CountryId});
    CustomerArticleCompanyResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Id = json['Id'];
        Name = json['Name'];
        LogoType = json['LogoType'];
        Email = json['Email'];
        Phone = json['Phone'];
        City = json['City'];
        Street1 = json['Street1'];
        ZipCode = json['ZipCode'];
        CountryId = json['CountryId'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Id': Id,
        'Name': Name,
        'LogoType': LogoType,
        'Email': Email,
        'Phone': Phone,
        'City': City,
        'Street1': Street1,
        'ZipCode': ZipCode,
        'CountryId': CountryId
    };

    getTypeName() => "CustomerArticleCompanyResponse";
    TypeContext? context = _ctx;
}

class PaymentLogResponse implements IConvertible
{
    int Id = 0;
    double? Amount;
    double? AmountCredited;
    String CurrencyId = "";
    String Comments = "";
    DateTime Created = DateTime(0);
    DateTime Updated = DateTime(0);

    PaymentLogResponse({this.Id,this.Amount,this.AmountCredited,this.CurrencyId,this.Comments,this.Created,this.Updated});
    PaymentLogResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Id = json['Id'];
        Amount = JsonConverters.toDouble(json['Amount']);
        AmountCredited = JsonConverters.toDouble(json['AmountCredited']);
        CurrencyId = json['CurrencyId'];
        Comments = json['Comments'];
        Created = JsonConverters.fromJson(json['Created'],'DateTime',context!);
        Updated = JsonConverters.fromJson(json['Updated'],'DateTime',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Id': Id,
        'Amount': Amount,
        'AmountCredited': AmountCredited,
        'CurrencyId': CurrencyId,
        'Comments': Comments,
        'Created': JsonConverters.toJson(Created,'DateTime',context!),
        'Updated': JsonConverters.toJson(Updated,'DateTime',context!)
    };

    getTypeName() => "PaymentLogResponse";
    TypeContext? context = _ctx;
}

class CustomerArticleResponse implements IConvertible
{
    int Id = 0;
    String CompanyId = "";
    int? ArticleId;
    double? Price;
    double? VAT;
    String CurrencyId = "";
    int StatusId = 0;
    String StatusName = "";
    String? CustomerId;
    DateTime CreatedDate = DateTime(0);
    DateTime UpdatedDate = DateTime(0);
    ArticleResponse Article;
    CustomerArticleCustomerResponse Customer;
    CustomerArticleCompanyResponse Company;
    List<PaymentLogResponse> PaymentLog = [];
    ResponseStatus ResponseStatus;

    CustomerArticleResponse({this.Id,this.CompanyId,this.ArticleId,this.Price,this.VAT,this.CurrencyId,this.StatusId,this.StatusName,this.CustomerId,this.CreatedDate,this.UpdatedDate,this.Article,this.Customer,this.Company,this.PaymentLog,this.ResponseStatus});
    CustomerArticleResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Id = json['Id'];
        CompanyId = json['CompanyId'];
        ArticleId = json['ArticleId'];
        Price = JsonConverters.toDouble(json['Price']);
        VAT = JsonConverters.toDouble(json['VAT']);
        CurrencyId = json['CurrencyId'];
        StatusId = json['StatusId'];
        StatusName = json['StatusName'];
        CustomerId = json['CustomerId'];
        CreatedDate = JsonConverters.fromJson(json['CreatedDate'],'DateTime',context!);
        UpdatedDate = JsonConverters.fromJson(json['UpdatedDate'],'DateTime',context!);
        Article = JsonConverters.fromJson(json['Article'],'ArticleResponse',context!);
        Customer = JsonConverters.fromJson(json['Customer'],'CustomerArticleCustomerResponse',context!);
        Company = JsonConverters.fromJson(json['Company'],'CustomerArticleCompanyResponse',context!);
        PaymentLog = JsonConverters.fromJson(json['PaymentLog'],'List<PaymentLogResponse>',context!);
        ResponseStatus = JsonConverters.fromJson(json['ResponseStatus'],'ResponseStatus',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Id': Id,
        'CompanyId': CompanyId,
        'ArticleId': ArticleId,
        'Price': Price,
        'VAT': VAT,
        'CurrencyId': CurrencyId,
        'StatusId': StatusId,
        'StatusName': StatusName,
        'CustomerId': CustomerId,
        'CreatedDate': JsonConverters.toJson(CreatedDate,'DateTime',context!),
        'UpdatedDate': JsonConverters.toJson(UpdatedDate,'DateTime',context!),
        'Article': JsonConverters.toJson(Article,'ArticleResponse',context!),
        'Customer': JsonConverters.toJson(Customer,'CustomerArticleCustomerResponse',context!),
        'Company': JsonConverters.toJson(Company,'CustomerArticleCompanyResponse',context!),
        'PaymentLog': JsonConverters.toJson(PaymentLog,'List<PaymentLogResponse>',context!),
        'ResponseStatus': JsonConverters.toJson(ResponseStatus,'ResponseStatus',context!)
    };

    getTypeName() => "CustomerArticleResponse";
    TypeContext? context = _ctx;
}

enum CustomerArticleStatusEnum
{
    AwaitingPayment,
    AwaitingPaymentFromProvider,
    AwaitingPaymentNoTimeLimit,
    Active,
    Off,
}

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class CreateCustomerArticle implements ICompany, IConvertible
{
    /**
    * 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.")
    String? CompanyId;

    /**
    * The article id to base this customer article on
    */
    // @ApiMember(Description="The article id to base this customer article on", IsRequired=true)
    int ArticleId = 0;

    /**
    * The customer id to assign the article to
    */
    // @ApiMember(Description="The customer id to assign the article to", IsRequired=true)
    String CustomerId = "";

    /**
    * The status of the customer article
    */
    // @ApiMember(Description="The status of the customer article")
    CustomerArticleStatusEnum? StatusId;

    /**
    * Optional price override. If not provided, uses the article price.
    */
    // @ApiMember(Description="Optional price override. If not provided, uses the article price.")
    double? Price;

    /**
    * Optional VAT override. If not provided, uses the article VAT.
    */
    // @ApiMember(Description="Optional VAT override. If not provided, uses the article VAT.")
    double? VAT;

    /**
    * Optional currency override. If not provided, uses the article currency.
    */
    // @ApiMember(Description="Optional currency override. If not provided, uses the article currency.")
    String CurrencyId = "";

    CreateCustomerArticle({this.CompanyId,this.ArticleId,this.CustomerId,this.StatusId,this.Price,this.VAT,this.CurrencyId});
    CreateCustomerArticle.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        CompanyId = json['CompanyId'];
        ArticleId = json['ArticleId'];
        CustomerId = json['CustomerId'];
        StatusId = JsonConverters.fromJson(json['StatusId'],'CustomerArticleStatusEnum',context!);
        Price = JsonConverters.toDouble(json['Price']);
        VAT = JsonConverters.toDouble(json['VAT']);
        CurrencyId = json['CurrencyId'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'CompanyId': CompanyId,
        'ArticleId': ArticleId,
        'CustomerId': CustomerId,
        'StatusId': JsonConverters.toJson(StatusId,'CustomerArticleStatusEnum',context!),
        'Price': Price,
        'VAT': VAT,
        'CurrencyId': CurrencyId
    };

    getTypeName() => "CreateCustomerArticle";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'api.bokamera.se', types: <String, TypeInfo> {
    'BaseModel': TypeInfo(TypeOf.Class, create:() => BaseModel()),
    'ArticleServiceRelation': TypeInfo(TypeOf.Class, create:() => ArticleServiceRelation()),
    'ArticleResponse': TypeInfo(TypeOf.Class, create:() => ArticleResponse()),
    'List<ArticleServiceRelation>': TypeInfo(TypeOf.Class, create:() => <ArticleServiceRelation>[]),
    'CustomerArticleCustomerResponse': TypeInfo(TypeOf.Class, create:() => CustomerArticleCustomerResponse()),
    'CustomerArticleCompanyResponse': TypeInfo(TypeOf.Class, create:() => CustomerArticleCompanyResponse()),
    'PaymentLogResponse': TypeInfo(TypeOf.Class, create:() => PaymentLogResponse()),
    'CustomerArticleResponse': TypeInfo(TypeOf.Class, create:() => CustomerArticleResponse()),
    'List<PaymentLogResponse>': TypeInfo(TypeOf.Class, create:() => <PaymentLogResponse>[]),
    'CustomerArticleStatusEnum': TypeInfo(TypeOf.Enum, enumValues:CustomerArticleStatusEnum.values),
    'CreateCustomerArticle': TypeInfo(TypeOf.Class, create:() => CreateCustomerArticle()),
});

Dart CreateCustomerArticle DTOs

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

HTTP + JSV

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/jsv
Content-Type: text/jsv
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/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
		}
	}
}