# FlattiesApi.UserApi

All URIs are relative to *https://endpoints-dot-flatties-test01.appspot.com/v1*

Method | HTTP request | Description
------------- | ------------- | -------------
[**addListing**](UserApi.md#addListing) | **POST** /user/{userId}/listings | Add a new listing to the user&#39;s listings.
[**getTestUsers**](UserApi.md#getTestUsers) | **GET** /users/test | Get a list of test users.
[**getUser**](UserApi.md#getUser) | **GET** /user/me | User profile
[**getUserListings**](UserApi.md#getUserListings) | **GET** /user/{userId}/listings | Get a user&#39;s listings.
[**loginUser**](UserApi.md#loginUser) | **POST** /user/login | Login a user and add the user if new.


<a name="addListing"></a>
# **addListing**
> &#39;Integer&#39; addListing(userId, listing, opts)

Add a new listing to the user&#39;s listings.



### Example
```javascript
var FlattiesApi = require('flatties_api');
var defaultClient = FlattiesApi.ApiClient.default;

// Configure OAuth2 access token for authorization: flatties_auth
var flatties_auth = defaultClient.authentications['flatties_auth'];
flatties_auth.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new FlattiesApi.UserApi();

var userId = 789; // Integer | The ID of the user to whom the listing belongs.

var listing = new FlattiesApi.Listing(); // Listing | Listing that needs to be added to the user's listings. At a minimum, an address with a town/city must be provided.

var opts = { 
  'tag': "tag_example" // String | An optional tag attached to any data created. Typically used for testing.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.addListing(userId, listing, opts, callback);
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **userId** | **Integer**| The ID of the user to whom the listing belongs. | 
 **listing** | [**Listing**](Listing.md)| Listing that needs to be added to the user&#39;s listings. At a minimum, an address with a town/city must be provided. | 
 **tag** | **String**| An optional tag attached to any data created. Typically used for testing. | [optional] 

### Return type

**&#39;Integer&#39;**

### Authorization

[flatties_auth](../README.md#flatties_auth)

### HTTP request headers

 - **Content-Type**: application/json
 - **Accept**: application/json

<a name="getTestUsers"></a>
# **getTestUsers**
> FacebookTestUsers getTestUsers(opts)

Get a list of test users.

Get the list of Facebook ids and access tokens for test users already set up and linked to Facebook. **Status:** Done but needs testing.

### Example
```javascript
var FlattiesApi = require('flatties_api');
var defaultClient = FlattiesApi.ApiClient.default;

// Configure OAuth2 access token for authorization: flatties_auth
var flatties_auth = defaultClient.authentications['flatties_auth'];
flatties_auth.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new FlattiesApi.UserApi();

var opts = { 
  'limit': 56, // Integer | An optional number of test users that are returned in each page. If zero or less, a default limit is used. Note that this is an upper limit. If there are not enough test users remaining in the list of data, then fewer will be returned.
  'start': "start_example" // String | An optional cursor that points to the starting page of data. Typically obtained from a previous call.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.getTestUsers(opts, callback);
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **limit** | **Integer**| An optional number of test users that are returned in each page. If zero or less, a default limit is used. Note that this is an upper limit. If there are not enough test users remaining in the list of data, then fewer will be returned. | [optional] 
 **start** | **String**| An optional cursor that points to the starting page of data. Typically obtained from a previous call. | [optional] 

### Return type

[**FacebookTestUsers**](FacebookTestUsers.md)

### Authorization

[flatties_auth](../README.md#flatties_auth)

### HTTP request headers

 - **Content-Type**: application/json
 - **Accept**: application/json

<a name="getUser"></a>
# **getUser**
> User getUser()

User profile

The user profile endpoint returns information about the Flatties user that has authorized with the application.

### Example
```javascript
var FlattiesApi = require('flatties_api');
var defaultClient = FlattiesApi.ApiClient.default;

// Configure OAuth2 access token for authorization: flatties_auth
var flatties_auth = defaultClient.authentications['flatties_auth'];
flatties_auth.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new FlattiesApi.UserApi();

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.getUser(callback);
```

### Parameters
This endpoint does not need any parameter.

### Return type

[**User**](User.md)

### Authorization

[flatties_auth](../README.md#flatties_auth)

### HTTP request headers

 - **Content-Type**: application/json
 - **Accept**: application/json

<a name="getUserListings"></a>
# **getUserListings**
> Listings getUserListings(userId, opts)

Get a user&#39;s listings.

Get a user&#39;s listings.

### Example
```javascript
var FlattiesApi = require('flatties_api');
var defaultClient = FlattiesApi.ApiClient.default;

// Configure OAuth2 access token for authorization: flatties_auth
var flatties_auth = defaultClient.authentications['flatties_auth'];
flatties_auth.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new FlattiesApi.UserApi();

var userId = 789; // Integer | The ID of the user to whom the listing belongs.

var opts = { 
  'limit': 56, // Integer | An optional number listings that are returned in each page. If zero or less, a default limit is used. Note that this is an upper limit. If there are not enough listings remaining in the list, then fewer will be returned.
  'start': "start_example" // String | An optional cursor that points to the starting page of data. Typically obtained from a previous call.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.getUserListings(userId, opts, callback);
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **userId** | **Integer**| The ID of the user to whom the listing belongs. | 
 **limit** | **Integer**| An optional number listings that are returned in each page. If zero or less, a default limit is used. Note that this is an upper limit. If there are not enough listings remaining in the list, then fewer will be returned. | [optional] 
 **start** | **String**| An optional cursor that points to the starting page of data. Typically obtained from a previous call. | [optional] 

### Return type

[**Listings**](Listings.md)

### Authorization

[flatties_auth](../README.md#flatties_auth)

### HTTP request headers

 - **Content-Type**: application/json
 - **Accept**: application/json

<a name="loginUser"></a>
# **loginUser**
> User loginUser(facebookId, facebookToken, opts)

Login a user and add the user if new.

Login a user and additionally add a new user if the user is new. Requires information obtained via a successful Facebook login. Refresh the Facebook user access token if the user already exists. The returned Flatties user access token will be used for authentication on other API calls.

### Example
```javascript
var FlattiesApi = require('flatties_api');
var defaultClient = FlattiesApi.ApiClient.default;

// Configure OAuth2 access token for authorization: flatties_auth
var flatties_auth = defaultClient.authentications['flatties_auth'];
flatties_auth.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new FlattiesApi.UserApi();

var facebookId = "facebookId_example"; // String | The facebook user id obtained via the Facebook API login.

var facebookToken = "facebookToken_example"; // String | The facebook access token obtained via the Facebook API login.

var opts = { 
  'tag': "tag_example" // String | An optional tag attached to any data created. Typically used for testing.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.loginUser(facebookId, facebookToken, opts, callback);
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **facebookId** | **String**| The facebook user id obtained via the Facebook API login. | 
 **facebookToken** | **String**| The facebook access token obtained via the Facebook API login. | 
 **tag** | **String**| An optional tag attached to any data created. Typically used for testing. | [optional] 

### Return type

[**User**](User.md)

### Authorization

[flatties_auth](../README.md#flatties_auth)

### HTTP request headers

 - **Content-Type**: application/json
 - **Accept**: application/json

