1.0.3 • Published 4 years ago
@boxoffice/optimus-api-wrapper v1.0.3
Mobile Movies API Wrapper
Wrapper library for Mobile Movies API
How to use this Wrapper
Download the source code of the wrapper and install the wrapper to your own project:
npm install @boxoffice/optimus-api-wrapper
Create an instance of this wrapper as below
const wrapper = require('mobile-movies-api-wrapper') const config = { isDebug, MOBILE_MOVIES_API_URL, authToken, exhibitorCode } const client = wrapper(config)
- isDebug - optional field. true: output debug information, false: no debug information.
- authToken - the authorization token.
- exhibitorCode - the exhibitor code (includes Prospector, RTSDemo, CinemaWest, BandBTheaters).
- MOBILE_MOVIES_API_URL - Mobile Movies API URL. E.g.
https://wmp-mobileapi-dev.azurewebsites.net
Every function in this wrapper will return a promise, Handling promises is at the caller end. Call the functions with appropriate arguments
E.g.
const theaterId = '7871'
const authToken = 'vSD45gbEgd5ggevbxjhg4655bvE='
const exhibitorCode = 'Prospector'
const reqQuery = {
firstDate: '2018-07-16',
lastDate: '2019-12-20'
}
// promise
client
.getSingleTheater(theaterId, reqQuery, authToken, exhibitorCode)
.then((result) => console.log(result.body, result.status))
.catch((err) => console.log(err))
// async/await
const result = await client.getSingleTheater(theaterId, reqQuery, authToken, exhibitorCode)
Refer index.js
for the list of available wrapper functions
Documentation for wrapper methods
All URIs are relative to MOBILE_MOVIES_API_URL configuration variable.
Theater Detail wrapper methods
Method | HTTP request | Description |
---|---|---|
getTheaters | GET /api/theaters | Get a list of Theaters for an Exhibitor. |
getSingleTheater | GET /api/theaters/single/:theaterId | Get a theater detail by theaterId. |
Movie Detail wrapper methods
Method | HTTP request | Description |
---|---|---|
getSingleMovie | GET /api/movies/single/:movieId | Get a movie detail by movieId. |
getNowPlaying | GET /api/movies/nowplaying | Get a list of Now Playing movies for an Exhibitor. |
getComingSoon | GET /api/movies/comingsoon | Get a list of Coming Soon movies for an Exhibitor. |
Emergency Messages wrapper methods
Method | HTTP request | Description |
---|---|---|
getEmergencyMessages | GET /api/emergency | Get EmergencyMessage objects. |
Orders wrapper methods
Method | HTTP request | Description |
---|---|---|
getOrderSummary | GET /api/orders/summary/:orderId | Get a summary of a (completed) order by orderId. |
getOrderForBooking | GET /api/orders/BookingSession/:bookingSessionId | Get order details for an in-progress booking. |
Compatibility wrapper methods
Method | HTTP request | Description |
---|---|---|
getCompatibility | GET /api/compatibility | Get compatibility information. |
Booking wrapper methods
Method | HTTP request | Description |
---|---|---|
createBooking | POST /api/Booking/CreateSession | Create a new booking session, optionally associated with a Member, for a specific item. |
cancelBooking | POST /api/Booking/CancelSession | Cancel a current booking session. Once cancelled the booking session cannot be retrieved. |
extendBooking | POST /api/Booking/ExtendSession | Extend a current booking session. |
completeBooking | POST /api/Booking/Complete | Complete the booking session by creating a final Order. |
Ticketing wrapper methods
Method | HTTP request | Description |
---|---|---|
selectTickets | POST /api/Ticketing/SelectTickets | Select the tickets to associate with the booking session. Any previous tickets will be overwritten. |
getTickets | GET /api/Ticketing/AvailableTickets/:bookingSessionId | Get the available tickets for associated with a booking session. |
Seating wrapper methods
Method | HTTP request | Description | |
---|---|---|---|
selectSeats | POST /api/Seating/SelectSeats | Set the selected seats against the booking. | |
getSeatingLayout | GET /api/Seating/GetLayout/:bookingSessionId | Get the seating layout for the screening associated with the supplied . |
Payment wrapper methods
Method | HTTP request | Description |
---|---|---|
initializePayment | POST /api/Payment/Initialize | Initialize payment provider. |
Loyalty wrapper methods
Method | HTTP request | Description |
---|---|---|
loginLoyalty | POST /api/Loyalty/Login | Sends credentials to log into the Loyalty system. |
refreshLoyalty | POST /api/Loyalty/RefreshSession | Refreshes the Member's logged-in state. |
logoutLoyalty | POST /api/Loyalty/Logout | Ends the Member's session and logs out of the Loyalty system. |
getLoyaltyProfile | POST /api/Loyalty/Profile | Retrieves a logged-in Member's profile. |
resetLoyaltyPassword | POST /api/Loyalty/PasswordReset | Invokes the password reset process. |
Authorization
Movies API wrapper internally use the authToken field to generate <Basic authToken
> and pass it in the x-Authorization header.
Lint
- Run lint:
npm run lint
- Run lint fix:
npm run lint:fix
Running tests
Preparation
Run npm install
to install dependencies.
To run tests alone
npm run test
To run unit tests with coverage report
npm run test:cov
Verification
See Verification.md