<commit_before># About

A simple Node.JS wrapper around the YaSabe business directory API

## Installation

YaSabe API is available through an installation from npm
[yasabe-api](https://npmjs.org/package/yasabe-api)

```javascript
npm install yasabe-api
```

## Usage

To use this library simply require the file and create a new instance of the module like so:

```javascript
var Yasabe = require('yasabe-api');
var yasabe = new Yasabe(username, password);
```

### Using Debug mode

The debug mode is set to false by default, when switched on the API parameters will be logged out along with the API call that is being called and the response.

```javascript
yasabe.debugMode(true);
```

### Using Test mode

Test mode is set to false by default, when switched on the module will use the YaSabe development environment to stop test data being added to the actual database.

```javascript
yasabe.testMode(true);
```

### Pulling records

The parameters for a search are as follows:

---

`terms` - fielded value to search for  
  `where` - location name (city, state, zipcode, (latitude, longitude))  
  `distance` - distance radius from center location  
  `page` - page number  
  `size` - number of items per page  
  `sort` - relevance, distance, buzz, authenticity, alpha, index, social, random  

---

A basic example of use is:

```javascript
var search_params = {
  terms: {
    phone: "7039554747",
    name: "<NAME>"
  }
  where: "New York",
  radius: 5
}

yasabe.search(search_params, function(err, search_results) {

  console.log(err, search_results);

})
```

### Adding records

Parameters for adding a record are as follows:

---

`source` - *your* content source identifier  
  `externalid` - the id you know this record as  
  `businessMatches` - one or more listing id corresponding to YaSabe record/s to be updated  
  `businessContent` - content to make available in YaSabe  
  `additionalContent` - free text content to make available in YaSabe  

---

Additional parameters you should really be aware of:

```
// YaSabe accepted payment types
var payment_types = {
  1: "Cash",
  2: "Check",
  3: "Visa",
  4: "Master Card",
  5: "Discover",
  6: "American Express",
  7: "Diners",
  8: "Debit",
  9: "Paypal"
}

// YaSabe accepted languages
var Languages = {
  2: "English",
  3: "Spanish"
}
```

Basic example:

```javascript
var yasabe_params = {
  externalid: "afoleyridealongs",
  businessMatches: [],
  source: "cops ride along directorate"
}

yasabe_params.business_content = {
  language: [2],
  stdname: "<NAME>",
  tagline: "Ride along with a cop"
  addressline1: "1154 Summit Dr",
  addressline2: "",
  city_text: "Beverly Hills",
  province: "Los Angeles",
  state: "CA",
  zipcode: "90210",
  showAddress: true,
  latitude: 34.0731,
  longitude: 118.3994,
  description: "Some text description",
  videoURL: "http://youtu.be/IqG1l4lScsg",
  facebook: "http://www.facebook.com/axel-foley",
  twitter: "http://www.twitter.com/axelf",
  phones: [
    {
      phoneNum: 7039554747,
      type: "Primary"
    }
  ],
  email: [
    "<EMAIL>"
  ],
  url: [
    "http://www.axels-super-adventures.com"
  ],
  cat: [
    {
      id: 228000000
    }
  ]
}

yasabe_params.additional_content = [
  {
    id: "images",
    type: "content",
    items: [
      {
        type: "GALLERY",
        id: "http://imgur.com/GSdzQAx"
      },
      {
        type: "LOGO",
        id: "http://imgur.com/VWJvqVA"
      }
    ]
  },
  {
    id: "common",
    type: "content",
    items: [
      {
        type: "tag",
        english: "drug busts"
      },
      {
        type: "tag",
        english: "ride along"
      },
      {
        type: "hoursText",
        english: "M-F 9am-5pm, Sa-Su Closed",
        id: "display"
      }
    ]
  }
]

yasabe.post(yasabe_params, function(err, data) {

  console.log(err, data);

})
```

### Updating a record

Updating a record is just the same as `post()` but you must pass in the YaSabe id you wish to update in the businessMatches array. This ID can be attained by a simple search.

### Deleting a record

Deleteing a record requires the basic parameters for adding or updating but nothing else. An example of this would be:

```
var yasabe_params = {
  externalid: "afoleyridealongs",
  businessMatches: ["id_of_YaSabe_record"],
  source: "cops ride along directorate"
}

yasabe.delete(yasabe_params, function(err, data) {

  console.log(err, data);

})
```

## Third-party libraries

[request](http://github.com/mikeal/request.git)  
  [underscore](http://underscorejs.org)<commit_msg>Updated the readme and package file<commit_after># About

A simple Node.JS wrapper around the YaSabe business directory API

## Installation

YaSabe API is available through an installation from npm  
  [yasabe-api](https://npmjs.org/package/yasabe-api)

```javascript
npm install yasabe-api
```

## Usage

To use this library simply require the file and create a new instance of the module like so:

```javascript
var Yasabe = require('yasabe-api');
var yasabe = new Yasabe(username, password);
```

### Using Debug mode

The debug mode is set to false by default, when switched on the API parameters will be logged out along with the API call that is being called and the response.

```javascript
yasabe.debugMode(true);
```

### Using Test mode

Test mode is set to false by default, when switched on the module will use the YaSabe development environment to stop test data being added to the actual database.

```javascript
yasabe.testMode(true);
```

### Pulling records

The parameters for a search are as follows:

---

`terms` - fielded value to search for  
  `where` - location name (city, state, zipcode, (latitude, longitude))  
  `distance` - distance radius from center location  
  `page` - page number  
  `size` - number of items per page  
  `sort` - relevance, distance, buzz, authenticity, alpha, index, social, random  

---

A basic example of use is:

```javascript
var search_params = {
  terms: {
    phone: "7039554747",
    name: "<NAME>"
  }
  where: "New York",
  radius: 5
}

yasabe.search(search_params, function(err, search_results) {

  console.log(err, search_results);

})
```

### Adding records

Parameters for adding a record are as follows:

---

`source` - *your* content source identifier  
  `externalid` - the id you know this record as  
  `businessMatches` - one or more listing id corresponding to YaSabe record/s to be updated  
  `businessContent` - content to make available in YaSabe  
  `additionalContent` - free text content to make available in YaSabe  

---

Additional parameters you should really be aware of:

```
// YaSabe accepted payment types
var payment_types = {
  1: "Cash",
  2: "Check",
  3: "Visa",
  4: "Master Card",
  5: "Discover",
  6: "American Express",
  7: "Diners",
  8: "Debit",
  9: "Paypal"
}

// YaSabe accepted languages
var Languages = {
  2: "English",
  3: "Spanish"
}
```

Basic example:

```javascript
var yasabe_params = {
  externalid: "afoleyridealongs",
  businessMatches: [],
  source: "cops ride along directorate"
}

yasabe_params.business_content = {
  language: [2],
  stdname: "<NAME>",
  tagline: "Ride along with a cop"
  addressline1: "1154 Summit Dr",
  addressline2: "",
  city_text: "Beverly Hills",
  province: "Los Angeles",
  state: "CA",
  zipcode: "90210",
  showAddress: true,
  latitude: 34.0731,
  longitude: 118.3994,
  description: "Some text description",
  videoURL: "http://youtu.be/IqG1l4lScsg",
  facebook: "http://www.facebook.com/axel-foley",
  twitter: "http://www.twitter.com/axelf",
  phones: [
    {
      phoneNum: 7039554747,
      type: "Primary"
    }
  ],
  email: [
    "<EMAIL>"
  ],
  url: [
    "http://www.axels-super-adventures.com"
  ],
  cat: [
    {
      id: 228000000
    }
  ]
}

yasabe_params.additional_content = [
  {
    id: "images",
    type: "content",
    items: [
      {
        type: "GALLERY",
        id: "http://imgur.com/GSdzQAx"
      },
      {
        type: "LOGO",
        id: "http://imgur.com/VWJvqVA"
      }
    ]
  },
  {
    id: "common",
    type: "content",
    items: [
      {
        type: "tag",
        english: "drug busts"
      },
      {
        type: "tag",
        english: "ride along"
      },
      {
        type: "hoursText",
        english: "M-F 9am-5pm, Sa-Su Closed",
        id: "display"
      }
    ]
  }
]

yasabe.post(yasabe_params, function(err, data) {

  console.log(err, data);

})
```

### Updating a record

Updating a record is just the same as `post()` but you must pass in the YaSabe id you wish to update in the businessMatches array. This ID can be attained by a simple search.

### Deleting a record

Deleteing a record requires the basic parameters for adding or updating but nothing else. An example of this would be:

```
var yasabe_params = {
  externalid: "afoleyridealongs",
  businessMatches: ["id_of_YaSabe_record"],
  source: "cops ride along directorate"
}

yasabe.delete(yasabe_params, function(err, data) {

  console.log(err, data);

})
```

## Third-party libraries

[request](http://github.com/mikeal/request.git)  
  [underscore](http://underscorejs.org)
{'fraction_non_alphanumeric': 0.12557527942143326, 'fraction_numerical': 0.015340784571553802, 'mean_word_length': 3.118682310469314, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2573834', 'n_tokens_mistral': 3217, 'n_tokens_neox': 3045, 'n_words': 968}