Skip to content

Commit

Permalink
Version 0.2.0-rc4
Browse files Browse the repository at this point in the history
  • Loading branch information
botnerd committed Apr 16, 2019
1 parent b1e4b9b commit 36901b7
Show file tree
Hide file tree
Showing 8 changed files with 464 additions and 1 deletion.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,4 @@ claim.
Licensee hereby agrees not to initiate class-action lawsuits against Licensor
in relation to this license and to compensate Licensor for any legal fees, cost
or attorney fees should any claim brought by Licensee against Licensor be
denied, in part or in full.
denied, in part or in full.
82 changes: 82 additions & 0 deletions doc/customer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Customers

Customers are managed via a `CustomerOperation`

A customer operation can be retrieved using the following.

```kotlin
val customerOperation = FlyBuy.getInstance(context).customer.getCustomerOperation()
```

## Observe the customer

Returns a `LiveData` stream of the current customer to observe. The customer received will either be the logged in user or `null`

```kotlin
val customer: Customer = customerOperation.customers
```

## Create a Customer

Create a customer account using information from the user. Consent should be collected from the user (e.g. checkboxes)

```kotlin
val customerInfo = CustomerInfo (
name = "Marty McFly",
carType = "DeLorean",
carColor = "Silver",
licensePlate = "OUTATIME"
)
val customerConsent = CustomerConsent(
termsOfService = true,
ageVerification = true
)

fun createProfile(): LiveData<WorkStatus> {
return customerOperation.create(customerInfo.value!!, customerConsent)
}
```

## Sign In

Sign the user in using existing credentials

```kotlin
val loginInfo = LoginInfo(
email = "test@example.com",
password = "password"
)

fun login(loginInfo: LoginInfo): LiveData<WorkStatus> {
return customerOperation.login(loginInfo)
}
```

## Sign out the current Customer

Signs out the current customer.

```kotlin
fun signOut(): LiveData<WorkStatus> {
return customerOperation.logout()
}
```

## Update a Customer

Update customer info for the logged in user

```kotlin
val customerInfo = CustomerInfo (
name = "Marty McFly",
carType = "DeLorean",
carColor = "Silver",
licensePlate = "OUTATIME"
)

fun update(customerInfo: CustomerInfo): LiveData<WorkStatus> {
return customerOperation.updateCustomer(customerInfo)
}
```


Binary file added doc/img/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions doc/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Introduction

The FlyBuy cloud service and mobile SDK from [Radius
Networks][1] enables developers to add FlyBuy functionality directly into their app for a full white label implementation of the service.

## Install

See the [quick start guide](quickstart.md) for details.

## Issues

For general service questions and help consult the Radius Networks [support knowledge base][2].

If you've found a problem in this library, perform a search under [Issues][3] in case it has already been reported. If you do not find any issue addressing it, feel free to [open a new one][3].

Your issue report should contain a title and a clear description of the issue
at a minimum. Please provide as much relevant information as possible to
replicate the issue. This should include the Android and library versions, a code
sample demonstrating the issue, and device OS information.

## License

Copyright (c) 2019 by Radius Networks. http://www.radiusnetworks.com. All Rights Reserved. Usage of this library implies agreement to abide by the [license
terms](https://github.com/RadiusNetworks/flybuy-ios/blob/master/LICENSE) and Radius Networks [terms of service][4].

[1]: http://www.radiusnetworks.com/
[2]: https://radiusnetworks.zendesk.com/
[3]: https://github.com/RadiusNetworks/flybuy-android/issues/new
[4]: http://www.radiusnetworks.com/terms_of_service.html
42 changes: 42 additions & 0 deletions doc/notifications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Notifications

FlyBuy can leverage Google's Firebase Cloud Messaging (FCM) to get updates about the status of an order. FlyBuy does not perform the push notification directly, instead it relies on the app to notify it that a new notification has been received. If you do not already handle FCM in your app, refer to the documentation at [Firebase](https://firebase.google.com) for details on how to integrate it in your app.

To pass the message to FlyBuy, override the `FirebaseMessagingService.onMessageReceived` method as follows.

```kotlin
override fun onMessageReceived(remoteMessage: RemoteMessage?) {
// result is a LiveData<WorkStatus> object that can be observed
val result = FlyBuy.onMessageReceived(remoteMessage)
}
```

You do not need to filter or check the body of the `remoteMessage` data, FlyBuy will inspect it and only process the notification if it is relevant to the SDK.

Since a device's push token can change, the FlyBuy SDK needs to be informed when that occurs. To do so, override the `FirebaseMessagingingService.onNewToken()` method as follows.

```kotlin
override fun onNewToken(token: String?) {
FlyBuy.getInstance(this).onNewPushToken(token)
}
```

The SDK should also be updated with the push token when the app starts. The following code snippet provides an example function that can be called from `onCreate()` in your activity.

```kotlin
private fun updatePushToken() {
FirebaseInstanceId.getInstance().instanceId
.addOnCompleteListener(OnCompleteListener { task ->
if (!task.isSuccessful) {
Timber.w(task.exception, "getInstanceId failed")
return@OnCompleteListener
}

// Get new Instance ID token
task.result?.token?.let {
FlyBuy.getInstance(this).onNewPushToken(it)
}

})
}
```
112 changes: 112 additions & 0 deletions doc/orders.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Orders

Orders are managed via a `OrdersOperation`

Each operation can be retrieved using the following:

```kotlin
val ordersOperation = FlyBuy.getInstance(context).orders.getOrdersOperation()
```

## Observe the orders

Returns a `LiveData` stream of orders

```kotlin
openOrders = getOrdersOperation.orders.open()
closedOrders = getOrdersOperation.orders.closed()
```

## Syncing Orders

Syncs the latest orders with the server and returns a `LiveData<WorkStatus>` stream for observing status

```kotlin
fun sync(): LiveData<WorkStatus>? {
return ordersOperation.sync()
}
```

## Redeem Order

First, check that an order exists for a given redeem code

```kotlin
fun checkCode(): LiveData<WorkStatus>? {
return redeemCode.value?.let {
ordersOperation.findOrder(it)
}
}
```

Claim the order for the customer for the given redeem code

```kotlin
fun redeemOrder(): LiveData<WorkStatus>? {
return listOf(redeemCode.value, customerInfo.value).any {it == null}.let {
null
} ?: run {
ordersOperation.claimOrder(redeemCode.value!!, customerInfo.value!!)
}
}
```

## Create Order

Create an order by passing order identifiers to the `create` method. There are numerous attributes available, but the only mandatory ones are the `siteID` and `partnerIdentifier`. Returns a `LiveData<WorkStatus>` stream for observing status

```kotlin
val info = CreateOrderInfo(
siteID = 101,
partnerIdentifier = "1234123",
customerCarColor = "#FF9900",
customerCarType = "Silver Sedan",
customerLicensePlate = "XYZ-456",
customerName = customerName
)

fun create(): LiveData<WorkStatus> {
return ordersOperation.findOrder(info)
}
```

#### Order Info attributes

| Attribute | Description |
| ---------------------- | ----------------------------------------------- |
| `siteID` | The FlyBuy Site Identifier |
| `partnerIdentifier` | Internal customer or order identifier. |
| `customerCarColor` | Color of the customer's vehicle |
| `customerCarType` | Make and model of the customer's vehicle |
| `customerLicensePlate` | License plate of the customer's vehicle |
| `customerName` | Customer's name |
| `pushToken` | The token used for push messages (or sent to the webhook) |

## Updating Orders

Orders are always updated with an Order Event. Returns a `LiveData<WorkStatus>` stream for observing status

```kotlin
fun create(): LiveData<WorkStatus> {
return ordersOperation.event(order, CustomerState.waiting)
}
```

#### Order Event attributes

| Attribute | Description |
| --------- | ---------------------- |
| `order` | The order data |
| `customerState` | Customer state ENUM value |

#### Customer State values

| Value | Description |
| ----------- | ------------------------------------------------------------------- |
| `created` | Order has been created |
| `enRoute` | Order tracking is started the customer is on their way |
| `nearby` | The customer is close to the site |
| `arrived` | The customer has arrived on premises |
| `waiting` | The customer is in a pickup area or manually said they were waiting |
| `completed` | The order is complete |

Loading

0 comments on commit 36901b7

Please sign in to comment.