1.0.3 • Published 4 years ago

@boxoffice/optimus-api-wrapper v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

Mobile Movies API Wrapper

Wrapper library for Mobile Movies API

How to use this Wrapper

  1. Download the source code of the wrapper and install the wrapper to your own project:

    npm install @boxoffice/optimus-api-wrapper
  2. 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
  3. 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

MethodHTTP requestDescription
getTheatersGET /api/theatersGet a list of Theaters for an Exhibitor.
getSingleTheaterGET /api/theaters/single/:theaterIdGet a theater detail by theaterId.

Movie Detail wrapper methods

MethodHTTP requestDescription
getSingleMovieGET /api/movies/single/:movieIdGet a movie detail by movieId.
getNowPlayingGET /api/movies/nowplayingGet a list of Now Playing movies for an Exhibitor.
getComingSoonGET /api/movies/comingsoonGet a list of Coming Soon movies for an Exhibitor.

Emergency Messages wrapper methods

MethodHTTP requestDescription
getEmergencyMessagesGET /api/emergencyGet EmergencyMessage objects.

Orders wrapper methods

MethodHTTP requestDescription
getOrderSummaryGET /api/orders/summary/:orderIdGet a summary of a (completed) order by orderId.
getOrderForBookingGET /api/orders/BookingSession/:bookingSessionIdGet order details for an in-progress booking.

Compatibility wrapper methods

MethodHTTP requestDescription
getCompatibilityGET /api/compatibilityGet compatibility information.

Booking wrapper methods

MethodHTTP requestDescription
createBookingPOST /api/Booking/CreateSessionCreate a new booking session, optionally associated with a Member, for a specific item.
cancelBookingPOST /api/Booking/CancelSessionCancel a current booking session. Once cancelled the booking session cannot be retrieved.
extendBookingPOST /api/Booking/ExtendSessionExtend a current booking session.
completeBookingPOST /api/Booking/CompleteComplete the booking session by creating a final Order.

Ticketing wrapper methods

MethodHTTP requestDescription
selectTicketsPOST /api/Ticketing/SelectTicketsSelect the tickets to associate with the booking session. Any previous tickets will be overwritten.
getTicketsGET /api/Ticketing/AvailableTickets/:bookingSessionIdGet the available tickets for associated with a booking session.

Seating wrapper methods

MethodHTTP requestDescription
selectSeatsPOST /api/Seating/SelectSeatsSet the selected seats against the booking.
getSeatingLayoutGET /api/Seating/GetLayout/:bookingSessionIdGet the seating layout for the screening associated with the supplied .

Payment wrapper methods

MethodHTTP requestDescription
initializePaymentPOST /api/Payment/InitializeInitialize payment provider.

Loyalty wrapper methods

MethodHTTP requestDescription
loginLoyaltyPOST /api/Loyalty/LoginSends credentials to log into the Loyalty system.
refreshLoyaltyPOST /api/Loyalty/RefreshSessionRefreshes the Member's logged-in state.
logoutLoyaltyPOST /api/Loyalty/LogoutEnds the Member's session and logs out of the Loyalty system.
getLoyaltyProfilePOST /api/Loyalty/ProfileRetrieves a logged-in Member's profile.
resetLoyaltyPasswordPOST /api/Loyalty/PasswordResetInvokes 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

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago