Supporting API REST Functions (Codeunit 10015848)
In this article
Get list of activity locations: UploadActivityLocations()
Get list of activity types: UploadActivityTypes()
Get list of activity products: UploadActivityProducts()
Get list of clients/contacts issued /sold allowances. products: UploadPurchasedAllowances()
Get list of clients/contacts Todays and future activities: UploadClientBookingsV2()
Get list of active promotions: UploadPromotions()
Get availability: GetAvailabilityV4()
Confirming Booking: ConfirmActivityv5()
Canceling Booking: CancelActivity()
Get additional charges: GetAdditionalCharges()
Change or insert additional charges to activity: SetAdditionalCharges()
Get list of attributes assigned on a given reservation or activity entry: GetAttributes()
Set attribute value on a given reservation or activity: SetAttribute()
Force entry into the Reservation table: InsertReservation()
Force update to a reservation: UpdateReservation()
Get list of all activities assigned to a reservation: UploadReservationActivities()
Get list of additional charges related to activity product: GetProductCharges()
When the web services have been published, the OData URL looks like this:
ODataV4/WebServiceName_ProcedureName?Company=CompanyName
Example:
http://localhost:8080/LSCentralMaster/ODataV4/ActivityWSOData_UploadActivityLocations?Company=CRONUS%20-%20LS%20Central
After building the URL you only need to change the name of the procedure or service.
Requests and responses
Request for services are in JSON format and all are POST methods. Responses are as follows:
{
"@odata.context": "BASEURL/$metadata#Edm.String",
"value" : "{
\"error\":0,
\"errorMessage\":\"\",
\"result\": ...
}"
}
The service response is in the "value" attribute. The response is JSON stringified and follows this structure:
error | Boolean. Indicates if there is an error on service action. |
errorMessage | Indicates more details about an error. |
result | Contains returning information of service request. Commonly, returns a JSON object, but sometimes an array. |
See also:
Checking Availability: GetAvailability()
Confirming Booking: ConfirmActivity()
Canceling Booking: CancelActivity()
Get list of activity locations: UploadActivityLocations()
UploadActivityLocations() :Text
This function returns a JSON with a list of activity locations.
Return values
ActivityLocations | Top level. List of activity locations |
---|---|
code | Location code |
description | Location description |
retailStore | Code. Retail store corresponding to location |
Get list of activity types: UploadActivityTypes()
UploadActivityTypes() :Text
This function returns a JSON with a list of activity types.
Result values
ActivityTypes | Top level. List of activity types |
---|---|
code | Type code |
description | Description |
Get list of activity products: UploadActivityProducts()
UploadActivityProducts() :Text
This function returns a JSON with a list of activity products. It filters on products that are configured as being available on Web which is a setting on the product.
Return values
ActivityProducts | Top level. List of activity products |
---|---|
productNo | Product code |
description | Description |
activityType | Code. Type of activity |
retailItem | Code. Retail Item Id. |
defaultQty | Decimal. Default qty to sell |
pricedPerPerson | Decimal. Price per person |
quantityCaption | Text. Caption for quantity label |
allowNoOfPersonChange | Boolean. true/false |
minQty | Decimal |
maxQty | Decimal |
minPersons | Decimal |
maxPersons | Decimal |
paymentRequired | Boolean |
defaultUnitPrice | Decimal |
priceCurrency | Currency code. It is getting from Activity Setup - "Web Currency Code" |
cancelPolicy | Cancel policy code |
cancelPolicyDescription | Cancel policy description |
productType | Option:
|
fixedLocation | Fixed location code |
Get list of clients/contacts issued /sold allowances. products: UploadPurchasedAllowances()
UploadPurchasedAllowances(ClientNo: Code[20]) :Text
This function returns a JSON with a list of clients/contacts issued/sold allowances. ClientNo required. It filters on allowances having the status POSTED.
Return values
IssuedAllowance | Top level. List of issued allowances |
---|---|
allowanceNo | Code |
productNo | Product No(Code) |
validLocation | Location code |
description | Description |
qtyIssued | Decimal |
dateIssued | Date of issue |
unitPrice | Decimal |
clientNo | Code |
clientName | Text |
expiryDate | Date of expiration |
quantityConsumed | Decimal |
issuedTotalAmount | Decimal |
Get list of clients/contacts Todays and future activities: UploadClientBookingsV2()
UploadClientBookingsV2(ClientNo: Code[20]; ActivityType:Code[20]) :Text
This function returns a JSON with a list of clients/contacts, today's and future activities. ClientNo is required. ActivityType is an optional filter.
Return values
Activitities | Top level. List of activities reservation |
---|---|
activityNo | Activity code |
productNo | Product code |
description | Description |
dateFrom | Date |
dateTo | Date |
timeFrom | Time |
timeTo | Time |
quantity | Decimal |
unitPrice | Decimal |
lineDiscountPercentage | Decimal |
totalAmount | Decimal |
status | Status code |
paymentStatus | Option:
|
location | Location code |
clientNo | Client No (Code) |
clientName | Text |
noOfPersons | Integer |
lineDiscountAmount | Decimal |
comment |
Text |
allowanceNo | Allowance No (Code) |
priceCurrency | Decimal. It is getting from Activity Setup - "Web Currency Code" |
cancelPolicy | Cancel policy code |
cancelPolicyDescription | Cancel policy description |
cancelAmount | Decimal |
Get list of active promotions: UploadPromotions()
UploadPromotions() : Text
This function returns a JSON with a list of active promotions. This filters on promotions having "Promotion View Setting" field different from None or "Show in Role Center", and "Date To" not blank and later than today.
Return values
ActivityPromotions | Top level. List of active promotions |
---|---|
productNo | Product No(Code) |
dateFrom | Location code |
dateTo | Description |
timeFrom | Decimal |
timeTo | Date of issue |
clubMembersOnly | Club member code |
isPriceorDiscount | Option:
|
priceOrDiscountValue | Decimal |
daySetting | Option:
|
priceDescription | Description of price |
location | Location code |
productName | Product name |
priceCurrency | Currency. It is getting from Activity Setup - "Web Currency Code" |
Get availability: GetAvailabilityV4()
GetAvailabilityV4(LocationNo: Code[20]; ProductNo: Code[20]; ActivityDate: Date; ClientNo: Code[20]; OptionalResource: Code[20]; PromoCode: Code[20]; ActivityNo: Code[20]; NoOfPersons: Integer; CustomerAccountNo: Code[20]) : Text
This function returns a JSON with a list of availability work.
Return values
AvailabilityWork | Top level. List of availability work |
---|---|
productNo | Product No(Code) |
availDate | Availability date |
weekDay | Text of weekday |
availTime | Time |
availability | Integer |
timeCaption | Caption for time label |
location | Location code |
price | Decimal |
optionalResourceNo | Resource No. |
optionalResourceName | Resource name |
location | Location code |
priceCurrency | Currency code. It is getting from Activity Setup - "Web Currency Code" |
comment | Text comment |
Confirming Booking: ConfirmActivityv5()
ConfirmActivityV5(LocationNo: Code[20]; ProductNo: Code[20]; ActivityDate: Date; ActivityTime: Time; ClientNo: Code[20]; OptionalResource: Code[20]; OptionalComment: Text[200]; SetQuantity: Decimal; SetNoOfPeople: Decimal; Paid: Boolean; PromoCode: Code[20]; ClientName: Text[100]; Email: Text[200]; CustomerAccountNo: Code[20]; Token: Code[50]; ReservationNo: Code[20]) : Text
This function confirms a booking and creates an activity reservation.
Return values
activityNo | The booking reference created in Business Central. Must be assigned on the basket entry and passed to Commerce as sales line Order Reference, if being paid using basket processes. |
unitPrice | The unit price to be passed to the retail basket. |
lineDiscount | The line discount percentage to be passed to the retail basket. |
totalAmount | The total net amount to be passed to the retail basket. |
currency | The currency code of the amounts. |
bookingRef | Reference assignment to be passed to the Commerce transaction for payment validation. |
retailItem | The retail item no. |
Canceling Booking: CancelActivity()
CancelActivity(ActivityNo :Code[20]): Text
This function cancels the activity and returns values to the retail basket, if the activity was already paid and needs to be refunded. Otherwise, return values will be zero. Cancellation policies may also affect the amounts returned.
An activity can only be canceled once.
Return amounts are only included if the activity was confirmed as Fully Paid through the Commerce process.
Return values
productNo | The booking reference created in Business Central. Must be assigned on the basket entry and passed to Commerce as sales line Order Reference, if being paid using basket processes. |
unitPrice | The unit price to be passed to the retail basket. |
lineDiscount | The line discount percentage to be passed to the retail basket. |
totalAmount | The total net amount to be passed to the retail basket. |
currency | The currency code of the amounts. |
bookingRef | Reference assignment to be passed to the Commerce transaction for payment validation. |
Get additional charges: GetAdditionalCharges()
GetAdditionalCharges(ActivityNo: Code[20]) :Text
This function returns a JSON with list with the required or optional additional charges for the Activity as applied automatically according to the product.
Parameter ActivityNo is required.
Change or insert additional charges to activity: SetAdditionalCharges()
SetAdditionalCharges(ActivityNo: Code[20]; LineNo: Integer; ProductType: Option Item,Deal; ProductNo: Code[20]; Qty: Decimal; Price: Decimal; DiscountPercentage: Decimal; UnitOfMeasure: Code[20]) : Text
Change or insert additional charges to activity. Each line has a sequence reference as returned by the GetAdditionalCharges import.
To create new additional charge, use a sequence number that does not previously exist. To remove an entry, have Product no. blank.
Get list of attributes assigned on a given reservation or activity entry: GetAttributes()
GetAttributes(Type: Option Reservation,Activity,ActivityProduct,Resource; LinkNo: Code[20]) : Text
This function returns a JSON with a list of attributes which are assigned on a given reservation or activity entry.
Required parameters : Type, LinkNo. Depending on the Type value, the LinkNo is either the reservation ID or the activity ID.
Set attribute value on a given reservation or activity: SetAttribute()
SetAttribute(Type: Option Reservation,Activity,ActivityProduct,Resource; LinkNo: Code[20]; AttributeCode: Code[20]; AttributeValue: Text[100]; AttributeSequence: Integer
) : Text
If the attribute does not exist in the entry, it is inserted. Otherwise the attribute is updated.
Required parameters : Type, LinkNo, AttributeCode. Depending on the Type value, the LinkNo is either the reservation ID or the activity ID.
Force entry into the Reservation table: InsertReservation()
InsertReservation(SetReservationNo: Code[20]; SetReservationType: Code[20]; SetResDateFrom: Date; SetResTimeFrom: Time; SetResDateTo: Date; SetResTimeTo: Time; SetCustomerAccount: Code[20]; SetDescription: Text[100]; SetComment: Text[100]; SetReference: Code[20]; SetContactNo: Code[20]; SetClientName: Text[100]; SetEmail: Text[50]; SetLocation: Code[20]; SetSalesPerson: Code[20]; SetInternalstatus: Integer; SetStatus: Code[20]) : Text
This function forces entry into the Reservation table.
If the SetReservationNo is left blank, the process automatically returns a new reservation number.
If the SetReservationNo parameter is populated, it is used as Reservation number. The same parameter is used to return the actual reservation number.
I nternal status and Status can be applied directly.
Blank fields are ignored.
Force update to a reservation: UpdateReservation()
UpdateReservation(ReservationNo: Code[20]; SetReservationType: Code[20]; SetResDateFrom: Date; SetResTimeFrom: Time; SetResDateTo: Date; SetResTimeTo: Time; SetCustomerAccount: Code[20]; SetDescription: Text[100]; SetComment: Text[100]; SetReference: Code[20]; SetContactNo: Code[20]; SetClientName: Text[100]; SetEmail: Text[200]; SetLocation: Code[20]; SetSalesPerson: Code[20]; SetInternalstatus: Integer; SetStatus: Code[20]) : Text
This function forces an update to a reservation in the Reservation table. Blank fields (or Zero) are ignored. ReservationNo is required.
Get list of all activities assigned to a reservation: UploadReservationActivities()
UploadReservationActivities(ReservationNo: Code[20]) :Text
This function returns a JSON with a list of all activities assigned to a reservation. ReservationNo is a required parameter.
Get list of additional charges related to activity product: GetProductCharges()
GetProductCharges(ProductNo: Code[20]; LocationNo: Code[20]; DateOfBooking: Date) : Text
This function returns a JSON with the additional charges related to activity product. ProductNo is a required parameter, but LocationNo (Activity location) is optional. If not set, the retail user assigned to the web service will provide the store settings for pricing, if retail pricing is needed.
Charge to reservation API's
These API's support the process of charging items to a reservation, either from external point of sale or from a point of sale residing in a different database. The API's are four and are called in the following sequence:
-
Retrieving list of reservations that are currently available for charging. This list is the same list as the one shown on the internal Point of sale when you select the Charge2Res pos command.
-
Initializing the reservation buffer for the receipt/reservation, and check if the reservation is valid for charging.
-
Charge single item/income entry to the reservation charge buffer, and validate towards restrictions (repeat for items in journal).
-
Finalize the reservation charge buffer, and check that the total amounts are matching. Finalize the charge buffer to actual charges.
See detailed list and parameters:
ChargeToReservationList
(ActivityLocation: Code[20]; ReservationType: Code[20]) ReservationEntriesRespond: Text
- Returns list of reservations based on activity location and optional the reservation type.
ChargeToReservationInitialize
(StoreNo: Code[10]; ReservationNo: Code[20]; ReceiptNo: Code[20]) JsonInitResponse: Text
Initializes the charge to reservation process (resets reservation charge buffer) and checks if the reservation exists and the receipt has not already been charged.
ChargeItemToReservation
(ReservationNo: Code[20]; StoreNo: Code[10]; ReceiptNo: Code[20]; LineNo: Integer; EntryType: Integer; ItemNo: Code[20]; VariantNo: Code[20]; UOM: Code[10]; Description: Text[200]; Qty: Decimal; Discount: Decimal; UnitPrice: Decimal; TotalAmount: Decimal; NetPrice: Decimal; VatAmount: Decimal; DiscountAmount: Decimal; Barcode: Code[30]; CashierID: Code[20]) JsonResponse: Text
Sends item/IncomeExpense Reservation charge buffer - EntryType 0 = item, EntryType 1 = Income, Refunds = negative qty and negative amount.
Restrictions are qualified based on the client restrictions setup. Note if same line number is sent, then it overwrites values for the specific line.
ChargeToReservationFinalPosting
(ReservationNo: Code[20]; StoreNo: Code[10]; ReceiptNo: Code[20]; TotalQty: Decimal; TotalAmount: Decimal) JsonResponse: Text
Sends posting confirmation and processes charge buffer, total values (for match verification). Validates that all lines have been received, checks restriction validations and moves entries from the temporary transaction records to actual charge transaction records and returns to caller if transaction was processed. No financial entries are posted.
Total quantity and total amount values are used to compare to reservation buffer total values and ensure match.
See also
Availability Token Request / Group-APIs