BokaMera.API.Host

<back to all web services

AddCompanyTrial

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/trials/company/Add new trial to a companyStart a new trial to the company for the logged in user.
import 'package:servicestack/servicestack.dart';

class TrialQueryResponse implements IConvertible
{
    int? Id;
    String? Name;
    int? TrialDays;

    TrialQueryResponse({this.Id,this.Name,this.TrialDays});
    TrialQueryResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Id = json['Id'];
        Name = json['Name'];
        TrialDays = json['TrialDays'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Id': Id,
        'Name': Name,
        'TrialDays': TrialDays
    };

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

class CompanyTrialQueryResponse implements IConvertible
{
    int? TrialTypeId;
    TrialQueryResponse? TrialType;
    DateTime? Started;
    DateTime? Created;
    DateTime? ValidTo;
    bool? Active;

    CompanyTrialQueryResponse({this.TrialTypeId,this.TrialType,this.Started,this.Created,this.ValidTo,this.Active});
    CompanyTrialQueryResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        TrialTypeId = json['TrialTypeId'];
        TrialType = JsonConverters.fromJson(json['TrialType'],'TrialQueryResponse',context!);
        Started = JsonConverters.fromJson(json['Started'],'DateTime',context!);
        Created = JsonConverters.fromJson(json['Created'],'DateTime',context!);
        ValidTo = JsonConverters.fromJson(json['ValidTo'],'DateTime',context!);
        Active = json['Active'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'TrialTypeId': TrialTypeId,
        'TrialType': JsonConverters.toJson(TrialType,'TrialQueryResponse',context!),
        'Started': JsonConverters.toJson(Started,'DateTime',context!),
        'Created': JsonConverters.toJson(Created,'DateTime',context!),
        'ValidTo': JsonConverters.toJson(ValidTo,'DateTime',context!),
        'Active': Active
    };

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

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class AddCompanyTrial 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;

    /**
    * Id of the trial type
    */
    // @ApiMember(Description="Id of the trial type", IsRequired=true)
    int? TrialTypeId;

    AddCompanyTrial({this.CompanyId,this.TrialTypeId});
    AddCompanyTrial.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        CompanyId = json['CompanyId'];
        TrialTypeId = json['TrialTypeId'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'CompanyId': CompanyId,
        'TrialTypeId': TrialTypeId
    };

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

TypeContext _ctx = TypeContext(library: 'api.bokamera.se', types: <String, TypeInfo> {
    'TrialQueryResponse': TypeInfo(TypeOf.Class, create:() => TrialQueryResponse()),
    'CompanyTrialQueryResponse': TypeInfo(TypeOf.Class, create:() => CompanyTrialQueryResponse()),
    'AddCompanyTrial': TypeInfo(TypeOf.Class, create:() => AddCompanyTrial()),
});

Dart AddCompanyTrial DTOs

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

HTTP + CSV

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

POST /trials/company/ HTTP/1.1 
Host: api.bokamera.se 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"CompanyId":"00000000-0000-0000-0000-000000000000","TrialTypeId":0}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"TrialTypeId":0,"TrialType":{"Id":0,"Name":"String","TrialDays":0},"Started":"0001-01-01T00:00:00","ValidTo":"0001-01-01T00:00:00","Active":false}