Rets-Rabbit-Angular
This is an angular module which provides a variety of factories and services which hit the Rets Rabbit API
Get Started
You can install this package via bower
$ bower install rets-rabbit-angular
Usage
Factories
This package comes with several factories:
- RRAuthFactory
- PropertyFactoryV1
- PropertyFactoryV2
RRAuthFactory
This factory has two publicly available methods:
- getTokenV1: returns a response from the Retsrabbit API containing an access_token
- getTokenV2: returns a response from the Retsrabbit API containing an access_token
getTokenV1
RRAuthFactory;
getTokenV2
RRAuthFactory;
PropertyFactoryV1
This factory has three public methods:
- search
- metadata
- servers
object search(string server_hash, string query)
object metadata(string serverh_hash)
PropertyFactoryV1;
object servers()
PropertyFactoryV1;
PropertyFactoryV2
This factory has three publicly available methods:
- search: accepts an unencoded ODATA query string and returns the results from the server
- findOne: find a single listing by ListingId
- metadata: fetch the metadata for your server
object search(string params)
var query = "$select=ListPrice, ListingId, OriginalListPrice&$filter=ListPrice gt OriginalListPrice&$orderby=ListPrice asc"; PropertyFactoryV2;
object findOne(int id, string query)
var id = '1234';var query = '$select=ListPrice, ListAgentFirstName'; PropertyFactoryV2;
object metadata()
PropertyFactoryV2;
Providers
This package comes with one provider:
- ApiConfig
ApiConfig
This provider has two different classes to handle setting the V1 and V2 config values. To access either class, you just need to append v1
or v2
to the provider.
This provider has several setters which can be used to configure the service inside of an angular config module.
-
setBaseUrl: Used to set the base url for querying. For example, https://api.retsrabbit.com/
-
setApiEndPoint: Used to set the specific versioning. For example, api/v2
-
setClientId: Used to set the client_id which can be found under the API page on the Retsrabbit dashboard
-
setClientSecret: Used to set the client_secret which can be found under the API page on the Retsrabbit dashboard
-
setStorageKey: Use to set the local storage key for the access_token sent back by the server.
An example of using the setters can be seen below.
Make sure you suffix the provider with the "Provider" keyword when injecting into a config module so that angular knows you are using it as a Provider and not a service/factory.
ApiConfigProviderv1; ApiConfigProviderv1; ApiConfigProviderv1; ApiConfigProviderv1;
The provider has several public getters which can be used to get api related information.
- baseUrl: Just returns the base url set in the getter
- apiUrl: Returns the base url plus the api endpoint
- clientId: Returns the client_id
- clientSecret: Returns the client_secret
- storageKey: Returns the local storage key for the access token