Skip to content

Commit

Permalink
Implemented missing roChannelStore methods #137
Browse files Browse the repository at this point in the history
  • Loading branch information
lvcabral committed Mar 9, 2023
1 parent e5df657 commit 400454c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ This emulator is still in **beta** stage, this way, there are several features f

## Out of Scope
* Roku OS User Interface.
* Roku Channel Store features.
* SDK 1.0 deprecated components.
56 changes: 54 additions & 2 deletions src/brsTypes/components/RoChannelStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ export class RoChannelStore extends BrsComponent implements BrsValue {
this.doOrder,
this.fakeServer,
this.getUserData,
this.getUserRegionData,
this.getPartialUserData,
this.storeChannelCredData,
this.getChannelCred,
// this.requestPartnerOrder,
// this.confirmPartnerOrder,
this.requestPartnerOrder,
this.confirmPartnerOrder,
],
ifSetMessagePort: [this.setMessagePort],
ifGetMessagePort: [this.getMessagePort],
Expand Down Expand Up @@ -191,6 +192,21 @@ export class RoChannelStore extends BrsComponent implements BrsValue {
},
});

/** Retrieves the state, zip code, and country associated with the customer's Roku account. */
private getUserRegionData = new Callable("getUserRegionData", {
signature: {
args: [],
returns: ValueKind.Object,
},
impl: (_: Interpreter) => {
let result = new Array<AAMember>();
result.push({ name: new BrsString("state"), value: new BrsString("") });
result.push({ name: new BrsString("zip"), value: new BrsString("") });
result.push({ name: new BrsString("country"), value: new BrsString("") });
return new RoAssociativeArray(result);
},
});

/** Provides a way to request user authorization to share his account information with the calling channel. */
private getPartialUserData = new Callable("getPartialUserData", {
signature: {
Expand Down Expand Up @@ -242,6 +258,42 @@ export class RoChannelStore extends BrsComponent implements BrsValue {
},
});

/** Checks the user's billing status and is a prerequisite for ConfirmPartnerOrder() when doing transactional purchases. */
private requestPartnerOrder = new Callable("requestPartnerOrder", {
signature: {
args: [
new StdlibArgument("orderInfo", ValueKind.Object),
new StdlibArgument("productId", ValueKind.String),
],
returns: ValueKind.Object,
},
impl: (_: Interpreter, orderInfo: RoAssociativeArray, productId: BrsString) => {
let result = new Array<AAMember>();
result.push({ name: new BrsString("errorCode"), value: new BrsString("-1") });
result.push({ name: new BrsString("errorMessage"), value: new BrsString("") });
result.push({ name: new BrsString("status"), value: new BrsString("Failure") });
return new RoAssociativeArray(result);
},
});

/** This function is equivalent to doOrder() for transactional purchases. */
private confirmPartnerOrder = new Callable("confirmPartnerOrder", {
signature: {
args: [
new StdlibArgument("confirmOrderInfo", ValueKind.Object),
new StdlibArgument("productId", ValueKind.String),
],
returns: ValueKind.Object,
},
impl: (_: Interpreter, confirmOrderInfo: RoAssociativeArray, productId: BrsString) => {
let result = new Array<AAMember>();
result.push({ name: new BrsString("errorCode"), value: new BrsString("-1") });
result.push({ name: new BrsString("errorMessage"), value: new BrsString("") });
result.push({ name: new BrsString("status"), value: new BrsString("Failure") });
return new RoAssociativeArray(result);
},
});

// ifGetMessagePort ----------------------------------------------------------------------------------

/** Returns the message port (if any) currently associated with the object */
Expand Down

0 comments on commit 400454c

Please sign in to comment.