C# Class Bloom.Api.ApiRequest

When the Bloom UI makes an API call, a method that has been registered to handle that endpoint is called and given one of these. That method uses this class to get information on the request, and also to reply to the caller.
The goal here is to reduce code while increasing clarity and error catching.
Show file Open project: BloomBooks/BloomDesktop Class Usage Examples

Public Properties

Property Type Description
CurrentBook Book.Book
CurrentCollectionSettings Bloom.Collection.CollectionSettings
Parameters System.Collections.Specialized.NameValueCollection

Public Methods

Method Description
ApiRequest ( IRequestInfo requestinfo, CollectionSettings currentCollectionSettings, Book currentBook ) : System
Failed ( string text ) : void
Handle ( EndpointRegistration endpointRegistration, IRequestInfo info, CollectionSettings collectionSettings, Book currentBook ) : bool
LocalPath ( ) : string

Get the actual local path that the server would retrieve given a Bloom URL that ends up at a local file. For now it is mainly useful for things in the book folder; it doesn't have all the smarts to locate files shipped with the application, it is just concerned with reversing the various tricks we use to encode paths as URLs.

ReplyWithImage ( string localPath ) : void
ReplyWithJson ( object objectToMakeJson ) : void
ReplyWithJson ( string json ) : void
ReplyWithText ( string text ) : void
RequiredFileNameOrPath ( string name ) : UrlPathString
RequiredParam ( string name ) : string
RequiredPostJson ( ) : string
RequiredPostString ( ) : string
RequiredPostValue ( string key ) : string
Succeeded ( ) : void
SucceededDoNotNavigate ( ) : void

Method Details

ApiRequest() public method

public ApiRequest ( IRequestInfo requestinfo, CollectionSettings currentCollectionSettings, Book currentBook ) : System
requestinfo IRequestInfo
currentCollectionSettings Bloom.Collection.CollectionSettings
currentBook Book
return System

Failed() public method

public Failed ( string text ) : void
text string
return void

Handle() public static method

public static Handle ( EndpointRegistration endpointRegistration, IRequestInfo info, CollectionSettings collectionSettings, Book currentBook ) : bool
endpointRegistration EndpointRegistration
info IRequestInfo
collectionSettings Bloom.Collection.CollectionSettings
currentBook Book
return bool

LocalPath() public method

Get the actual local path that the server would retrieve given a Bloom URL that ends up at a local file. For now it is mainly useful for things in the book folder; it doesn't have all the smarts to locate files shipped with the application, it is just concerned with reversing the various tricks we use to encode paths as URLs.
public LocalPath ( ) : string
return string

ReplyWithImage() public method

public ReplyWithImage ( string localPath ) : void
localPath string
return void

ReplyWithJson() public method

public ReplyWithJson ( object objectToMakeJson ) : void
objectToMakeJson object
return void

ReplyWithJson() public method

public ReplyWithJson ( string json ) : void
json string
return void

ReplyWithText() public method

public ReplyWithText ( string text ) : void
text string
return void

RequiredFileNameOrPath() public method

public RequiredFileNameOrPath ( string name ) : UrlPathString
name string
return UrlPathString

RequiredParam() public method

public RequiredParam ( string name ) : string
name string
return string

RequiredPostJson() public method

public RequiredPostJson ( ) : string
return string

RequiredPostString() public method

public RequiredPostString ( ) : string
return string

RequiredPostValue() public method

public RequiredPostValue ( string key ) : string
key string
return string

Succeeded() public method

public Succeeded ( ) : void
return void

SucceededDoNotNavigate() public method

public SucceededDoNotNavigate ( ) : void
return void

Property Details

CurrentBook public property

public Book.Book CurrentBook
return Book.Book

CurrentCollectionSettings public property

public CollectionSettings,Bloom.Collection CurrentCollectionSettings
return Bloom.Collection.CollectionSettings

Parameters public property

public NameValueCollection,System.Collections.Specialized Parameters
return System.Collections.Specialized.NameValueCollection