# irelia-database

Models and migrations for the database.

## Dependencies

- [git](https://git-scm.com/downloads)
- [nodejs](https://nodejs.org/en/download/) ^v9.6.1
- [yarn](https://yarnpkg.com/en/)
- [PostgreSQL](https://www.postgresql.org/download/)

You need a local running database with access to the current user.

## Documentation

To find out more, check the documentation:
http://docs.sequelizejs.com/manual/installation/getting-started.html

## Setup

```bash
git clone https://KevChips@bitbucket.org/profitfy/irelia-database.git
cd irelia-database
yarn install
```

## Service

### Plan - Functions

---

#### - savePlan

##### Parameters

- `planData`: Plan Data.

##### Return

An object with Plan data.

#### - listPlans

##### Parameters

- This method has not parameter

##### Return

A list of Plan data.

#### - listPlanById

##### Parameters

- `planId`: Plan Id.

##### Return

An object with Plan data filtered by id.

#### - listPlanByName

##### Parameters

- `planName`: Plan Name.

##### Return

An object with Plan data filtered by name.

#### - updatePlanById

##### Parameters

- `planId`: Plan Id.
- `planData`: Plan Data.

##### Return

An object with Plan data updated.

### DashboardUser - Functions

---

#### - saveDashboardUser

##### Parameters

- `dashboardUserData`: Dashboard User Data.

##### Return

An object with Dashboard User data.

#### - listDashboardUsers

##### Parameters

- This method has not parameter

##### Return

A list of Dashboard User data.

#### - listDashboardUsersByEmail

##### Parameters

- `dashboardUserEmails`: Array With Dashboard User Email.

##### Return

A list of Dashboard User data filtered by email.

#### - listDashboardUserByEmail

##### Parameters

- `dashboardUserEmail`: Dashboard User email.

##### Return

An object with Dashboard User data filtered by email.

#### - listDashboardUserToLogin

##### Parameters

- `dashboardUserEmail`: Dashboard User email.

##### Return

An object with Dashboard User data with password.

#### - listDashboardUserById

##### Parameters

- `dashboardUserId`: Dashboard User id.

##### Return

An object with Dashboard User data filtered by id.

#### - listDashboardUserByResetToken

##### Parameters

- `passwordResetToken`: Dashboard User Password Reset Token.

##### Return

An object with Dashboard User data filtered by id.

#### - listDashboardUsersActive

##### Parameters

- This method has not parameter

##### Return

A list of objects with all Dashboard User data filtered by active true.

#### - listDashboardUsersInactive

##### Parameters

- This method has not parameter

##### Return

A list of Dashboard User data filtered by active false.

#### - updateDashboardUserById

##### Parameters

- `dashboardUserId`: Dashboard User id.
- `dashboardUserData`: Dashboard User data to update.

##### Return

An object with Dashboard User data updated.

#### - deleteDashboardUserById

##### Parameters

- `dashboardUserId`: Dashboard User id.

##### Return

An object wih Dashboard User data deleted.

#### - updateDashboardUserPlan

##### Parameters

- `dashboardUserId`: Dashboard User id.
- `planId`: Plan id.

##### Return

An object with Dashboard User data updated.

### Notification - Functions

---

#### - saveNotification

##### Parameters

- `notificationData`: Notification Data.

##### Return

An object with Notification data.

#### - listNotificationById

##### Parameters

- `notificationId`: Notification Id.

##### Return

An object with Notification data filtered by id.

#### - listNotificationByDashboardUserId

##### Parameters

- `dashboardUserId`: Dashboard User Id.

##### Return

An object with Notification data filtered by dashboard user id.

#### - updateNotificationById

##### Parameters

- `notificationId`: Notification Id.
- `notificationData`: Notification Data.

##### Return

An object with Notification data updated.

### Subscription - Functions

---

#### - saveSubscription

##### Parameters

- `subscriptionData`: Subscription Data.

##### Return

An object with Subscription data.

#### - listSubscriptionById

##### Parameters

- `subscriptionId`: Subscription Id.

##### Return

An object with Subscription data filtered by id.

#### - listSubscriptionByDashboardUserId

##### Parameters

- `dashboardUserId`: Dashboard User Id.

##### Return

An object with Subscription data filtered by dashboard user id.

#### - updateSubscriptionById

##### Parameters

- `subscriptionId`: Subscription Id.
- `subscriptionData`: Subscription Data.

##### Return

An object with Subscription data updated.

### Mercado Pago Credential - Functions

---

#### - saveMercadoPagoCredential

##### Parameters

- `mercadoPagoCredentialData`: Mercado Pago Credential Data.

##### Return

An object with Mercado Pago Credential data.

#### - saveMercadoPagoCredentialWithStore

##### Parameters

- `mercadoPagoCredentialData`: Object With Mercado Pago Credential Data.
- `shopifyStoreSlug`: Object With Shopify Store Slug.

##### Return

An object with Mercado Pago Credential data.

#### - listMercadoPagoCredentials

##### Parameters

- This method has not parameter

##### Return

A list of objects with Mercado Pago Credential data.

#### - listMercadoPagoCredentialById

##### Parameters

- `mercadoPagoCredentialId`: Mercado Pago Credential Id.

##### Return

An object with Mercado Pago Credential data filtered by id.

#### - listMercadoPagoCredentialByShopifyStoreSlug

##### Parameters

- `shopifyStoreSlug`: Shopify Store Slug.

##### Return

An object with Mercado Pago Credential data filtered by shopify store slug.

#### - updateMercadoPagoCredentialById

##### Parameters

- `mercadoPagoCredentialId`: Mercado Pago Credential Id.
- `mercadoPagoCredentialData`: Mercado Pago Credential Data.

##### Return

An object with Mercado Pago Credential data updated.

### Shopify Store - Functions

---

#### - saveShopifyStore

##### Parameters

- `shopifyStoreData`: Shopify Store Data.

##### Return

An object with Shopify Store data.

#### - saveShopifyStoreProductsVariantsAndOrders

##### Parameters

- `shopifyProductsData`: Shopify Store Products Data.
- `shopifyVariantsData`: Shopify Store Variants Data.

##### Return

This function does not has a return.

#### - listShopifyStores

##### Parameters

- This method has not parameter

##### Return

A list of Shopify Store data.

#### - listShopifyStoreByDomain

##### Parameters

- `shopifyStoreDomain`: Shopify Store Domain.

##### Return

An object with Shopify Store data filtered by domain.

#### - listShopifyStoreById

##### Parameters

- `shopifyStoreId`: Shopify Store Id.

##### Return

An object with Shopify Store data filtered by id.

#### - getStoreAndProfitByDates

##### Parameters

- `shopifyStoreSlug`: Object With Shopify Store Slug.
- `startDate`: Object With Start Date.
- `endDate`: Object With End Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

An object with Shopify Store data with calculated profit by range of start date to end date.

#### - listShopifyStoresCreatedByDate

##### Parameters

- `startDate`: Object With Start Date.
- `endDate`: Object With End Date.

##### Return

A list of Shopify Store data filtered by created at by range of start date to end date.

#### - listActiveShopifyStores

##### Parameters

- `offset`: Object With Page Number.
- `limit`: Object With Elements Quantity Per Page.

##### Return

A list of actives Shopify Store data.

#### - listInactiveShopifyStores

##### Parameters

- `offset`: Object With Page Number.
- `limit`: Object With Elements Quantity Per Page.

##### Return

A list of inactives Shopify Store data.

#### - listShopifyStoreBySlug

##### Parameters

- `shopifyStoreSlug`: Shopify Store Slug.

##### Return

An object with Shopify Store data filtered by slug.

#### - listShopifyStoreWithMercadoPagoCredentialBySlug

##### Parameters

- `shopifyStoreSlug`: Shopify Store Slug.

##### Return

An object with Shopify Store data filtered by slug.

#### - listShopifyStoresByUserId

##### Parameters

- `dashboardUserId`: Dashboard User Id.

##### Return

A list of Shopify Store data filtered by dashboard user id.

#### - updateShopifyStoreById

##### Parameters

- `shopifyStoreId`: Shopify Store Id.
- `shopifyStoreData`: Shopify Store Data.

##### Return

An object with Shopify Store data updated.

### Shopify Product - Functions

---

#### - saveShopifyProduct

##### Parameters

- `shopifyProductData`: Shopify Product Data.

##### Return

An object with Shopify Store Data.

#### - saveShopifyProducts

##### Parameters

- `shopifyProductsData`: An array with Shopify Product Data.

##### Return

A list of Shopify Product data what was inserted.

#### - listShopifyProductsWithStore

##### Parameters

- `shopifyStoreIds`: Object With An Array Of Shopify Store Ids.

##### Return

A list of Shopify Product data filtered by Shopify Store ids.

#### - getStoreAndProfitByDates

##### Parameters

- `shopifyProductSlug`: Object With Shopify Product Slug.
- `startDate`: Object With Start Date.
- `endDate`: Object With End Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

An object with Shopify Product data with calculated profit by range of start date to end date.

#### - listShopifyProducts

##### Parameters

- This method has not parameter

##### Return

A list of Shopify Product data.

#### - listShopifyProductById

##### Parameters

- `shopifyProductId`: Shopify Product Id.

##### Return

An object with Shopify Product data filtered by id.

#### - listShopifyProductBySlug

##### Parameters

- `shopifyProductSlug`: Shopify Product Slug.

##### Return

A list of Shopify Product data filtered by slug.

#### - listShopifyProductsByStoreId

##### Parameters

- `shopifyStoreId`: Object With Shopify Product Id.
- `offset`: Object With Page Number.
- `limit`: Object With Elements Quantity Per Page.

##### Return

A list of Shopify Product data filtered by store id.

#### - updateShopifyProductById

##### Parameters

- `shopifyProductId`: Shopify Product Id.
- `shopifyProductData`: Shopify Product Data.

##### Return

An object with Shopify Product data updated.

#### - updateShopifyProductBySlug

##### Parameters

- `shopifyProductSlug`: Shopify Product Slug.
- `shopifyProductData`: Shopify Product Data.

##### Return

An object with Shopify Product data updated.

### Shopify Variant - Functions

---

#### - saveShopifyVariant

##### Parameters

- `shopifyVariantData`: Shopify Variant Data.

##### Return

An object with Store data.

#### - saveShopifyVariants

##### Parameters

- `shopifyVariantsData`: An Array With Shopify Variant Data.

##### Return

Do not have return.

#### - listShopifyVariantsByProductId

##### Parameters

- `shopifyProductId`: Shopify Product Id.

##### Return

A list of Shopify Variant data filtered by product id.

#### - listShopifyVariantById

##### Parameters

- `shopifyVariantId`: Shopify Variant Id.

##### Return

A list of objects with Shopify Variant data filtered by id.

#### - updateShopifyVariantById

##### Parameters

- `shopifyVariantId`: Shopify Variant Id.
- `shopifyVariantData`: Shopify Variant Data.

##### Return

An object with Shopify Variant data updated.

### Shopify Store Profit - Functions

---

#### - saveShopifyStoreProfit

##### Parameters

- `shopifyStoreProfitData`: Shopify Store Profit Data.

##### Return

An object with Shopify Store Profit data.

#### - saveShopifyStoreProfits

##### Parameters

- `shopifyStoreProfitsData`: An Array With Shopify Store Profit Data.

##### Return

A list of Shopify Store Profit data that was inserted.

#### - listShopifyStoreProfitByStoreId

##### Parameters

- `shopifyStoreId`: Shopify Store Id.

##### Return

An object with Shopify Store Profit data filtered by store id.

#### - getDataToShowChart

##### Parameters

- `shopifyStoreId`: Object With Shopify Store Id.
- `startDate`: Object With Start Date.
- `endDate`: Object With End Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

An list with formatted data to show profit chart.

#### - listTodayShopifyStoreProfitByStoreId

##### Parameters

- `shopifyStoreId`: Object With Shopify Store Id.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

An object with today Shopify Store Profit.

#### - updateShopifyStoreProfitById

##### Parameters

- `shopifyStoreProfitId`: Shopify Store Profit Id.
- `shopifyStoreProfitData`: Shopify Store Profit Data.

##### Return

An object with Shopify Store Profit data updated.

### Shopify Product Profit - Functions

---

#### - saveShopifyProductProfit

##### Parameters

- `shopifyProductProfitData`: Shopify Product Profit Data.

##### Return

An object with Shopify Product Profit data.

#### - saveShopifyProductProfits

##### Parameters

- `shopifyProductProfitsData`: An Array With Shopify Product Profit Data.

##### Return

A list of Shopify Product Profit data that was inserted.

#### - listShopifyProductProfitsByProductId

##### Parameters

- `shopifyProductId`: Shopify Product Id.

##### Return

A list of Shopify Product Profit data filtered by product id.

#### - listShopifyProductsProfitsByStore

##### Parameters

- `shopifyStoreSlug`: Object With Shopify Store Slug.
- `limit`: Object With Elements Quantity Per Page.

##### Return

A list of Shopify Products data filtered by store slug.

#### - listTodayShopifyProductProfitByProductId

##### Parameters

- `shopifyProductId`: Object With Shopify Product Id.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

An object with today Shopify Product Profit.

#### - updateShopifyProductProfitById

##### Parameters

- `shopifyProductProfitId`: Shopify Product Profit Id.
- `shopifyProductProfitData`: Shopify Product Profit Data.

##### Return

An object with Shopify Product Profit data updated.

### Shopify Order - Functions

---

#### - saveShopifyOrder

##### Parameters

- `shopifyOrderData`: Shopify Order Data.

##### Return

An object with Shopify Order data.

#### - saveShopifyOrders

##### Parameters

- `shopifyOrdersData`: An array with Shopify Orders Data.

##### Return

Do not have return.

#### - listOrdersAndMercadoPagoCredentialByShopifyStoresId

##### Parameters

- `shopifyStoreIds`: Object With Shopify Store Ids.
- `startDate`: Object With Start Date.
- `endDate`: Object With End Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

A list of Shopify Order data and Mercado Pago Credential filtered by range of startDate to endDate.

#### - listShopifyOrdersUpdatedByDate

##### Parameters

- `shopifyStoreId`: Object With Shopify Store Id.
- `startDate`: Object With Start Date.
- `endDate`: Object With End Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

A list of Shopify Order data filtered by updated at and range of startDate to endDate.

#### - listShopifyOrdersCreatedByDate

##### Parameters

- `shopifyStoreId`: Object With Shopify Store Id.
- `startDate`: Object With Start Date.
- `endDate`: Object With End Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

A list of Shopify Order data filtered by created at and range of startDate to endDate.

### Shopify Custom Spend - Functions

---

#### - saveShopifyCustomSpend

##### Parameters

- `shopifyCustomSpendData`: Object With Shopify Custom Spend Data.
- `tz`: Object With Shopify Store Timezone.

##### Return

An object with Shopify Custom Spend data.

#### - listShopifyCustomSpendsByShopifyStoreId

##### Parameters

- `shopifyStoreId`: Shopify Store Id.

##### Return

A list of objects with Shopify Custom Spend data filtered by Shopify Store id.

#### - listShopifyCustomSpendById

##### Parameters

- `shopifyCustomSpendId`: Shopify Custom Spend Id.

##### Return

An object with Shopify Custom Spend data filtered by id.

#### - listShopifyCustomSpendsByBillingDate

##### Parameters

- `shopifyStoreId`: Object With Shopify Store Id.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

A list of Shopify Custom Spend data filtered by billing date and Shopify Store id.

#### - listAndUpdateShopifyCustomSpendsByYesterdayBillingDate

##### Parameters

- `shopifyStoreId`: Object With Shopify Store Id.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

A list of Shopify Custom Spend data filtered by yesterday billing date and Shopify Store id.

#### - updateShopifyCustomSpendById

##### Parameters

- `shopifyCustomSpendId`: Object With Shopify Custom Spend Id.
- `shopifyCustomSpendData`: Object With Shopify Custom Spend Data.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

An object with Shopify Custom Spend data updated.

### Shopify Custom Spend Billing - Functions

---

#### - saveShopifyCustomSpendBilling

##### Parameters

- `shopifyCustomSpendBillingData`: Shopify Custom Spend Billing Data.

##### Return

An object with Shopify Custom Spend data.

#### - listShopifyCustomSpendsBillingByBillingDate

##### Parameters

- `shopifyStoreId`: Object With Shopify Store Id.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

A list of Shopify Custom Spend Billing data filtered by billing date and Shopify Store id.

#### - listShopifyCustomSpendBillingByBillingDate

##### Parameters

- `shopifyStoreId`: Object With Shopify Store Id.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

An object Custom Spend Billing data filtered by billing date and Shopify Store id.

#### - updateShopifyCustomSpendBillingById

##### Parameters

- `shopifyCustomSpendBillingId`: Shopify Custom Spend Billing Id.
- `shopifyCustomSpendBillingData`: Shopify Custom Spend Billing Data.

##### Return

An object with Shopify Custom Spend Billing data updated.

### Facebook Credential - Functions

---

#### - saveFacebookCredential

##### Parameters

- `facebookCredentialData`: Facebook Credential Data.

##### Return

An object with Facebook Credential data.

#### - listFacebookCredentials

##### Parameters

- This method has not parameter

##### Return

A list of objects with Facebook Credential data.

#### - listFacebookCredentialById

##### Parameters

- `facebookCredentialId`: Facebook Credential Id.

##### Return

An object with Facebook Credential data filtered by id.

#### - listFacebookCredentialByUserId

##### Parameters

- `dashboardUserId`: Dashboard User Id.

##### Return

An object with Facebook Credential data filtered by dashboard user id.

#### - updateFacebookCredentialById

##### Parameters

- `facebookCredentialId`: Facebook Credential Id.
- `facebookCredentialData`: Facebook Credential Data.

##### Return

An object with Facebook Credential data updated.

#### - deleteFacebookCredentialByDashboardUser

##### Parameters

- `dashboardUserId`: Dashboard User Id.

##### Return

An object with Facebook Credential data deleted.

### Facebook Ad Account - Functions

---

#### - saveFacebookAdAccount

##### Parameters

- `facebookAdAccountData`: Facebook Ad Account data.

##### Return

An object with Facebook Ad Account data.

#### - saveFacebookAdAccounts

##### Parameters

- `facebookAdAccountsData`: Array With Facebook Ad Account Data.

##### Return

An object with Facebook Ad Account data.

#### - saveFacebookAdAccountsActive

##### Parameters

- `facebookAdAccountsData`: Array With Facebook Ad Account Data With Active Property.

##### Return

An object with Facebook Ad Account data.

#### - listFacebookAdAccounts

##### Parameters

- This method has not parameter

##### Return

A list of Facebook Ad Account data.

#### - listFacebookAdAccountById

##### Parameters

- `adAccountId`: Facebook Ad Account Id.

##### Return

An object with Facebook Ad Account data filtered by id.

#### - listFacebookAdAccountByDashboardUserId

##### Parameters

- `dashboardUserId`: Object With Dashboard User Id.
- `shopifyStoreId`: Object With Shopify Store id.

##### Return

A list of Facebook Ad Account data filtered by Dashboard User id and Shopify Store id.

#### - listActiveFacebookAdAccountByDashboardUserId

##### Parameters

- `dashboardUserId`: Dashboard User Id.

##### Return

A list with Facebook Ad Account data filtered by Dashboard User id.

#### - listFacebookAdAccountByShopifyStoreId

##### Parameters

- `shopifyStoreId`: Shopify Store Id.

##### Return

A list Facebook Ad Account data filtered by Shopify Store id.

#### - listActiveFacebookAdAccountByShopifyStoreId

##### Parameters

- `shopifyStoreId`: Shopify Store Id.

##### Return

A list Facebook Ad Account data filtered by Shopify Store id.

#### - updateFacebookAdAccountById

##### Parameters

- `adAccountId`: Object With Facebook Ad Account Id.
- `adAccountData`: Object With Facebook Ad Account Data.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

An object with Facebook Ad Account data updated.

#### - deleteFacebookAdAccountsByDashboardUser

##### Parameters

- `dashboardUserId`: Object With Dashboard User Id.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

A list of Facebook Ad Account data deleted.

### Facebook Ad Account Insight - Functions

---

#### - saveFacebookAdAccountInsight

##### Parameters

- `facebookAdAccountInsightData`: Facebook Ad Account Insight Data.

##### Return

An object with Facebook Ad Account Insight data.

#### - listFacebookAdAccountsInsightByInsightDate

##### Parameters

- `shopifyStoreId`: Object With Shopify Store Id.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

A list of Facebook Ad Accounts Insight filtered by Shopify Store id and today date.

#### - listFacebookAdAccountInsightByInsightDate

##### Parameters

- `facebookAdAccountId`: Object With Facebook Ad Account Id.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

A list of Facebook Ad Accounts Insight filtered by insight date, Facebook Ad Account id and today date.

#### - updateFacebookAdAccountInsightById

##### Parameters

- `facebookAdAccountInsightId`: Facebook Ad Account Insight Id.
- `facebookAdAccountInsightData`: Facebook Ad Account Insight Data.

##### Return

An object with Facebook Ad Account Insight data updated.

### Facebook Campaign - Functions

---

#### - saveFacebookCampaign

##### Parameters

- `facebookCampaignData`: Facebook Campaign Data.

##### Return

An object with Facebook Campaign data.

#### - saveFacebookCampaigns

##### Parameters

- `facebookCampaignData`: Array With Facebook Campaign Data.

##### Return

A list of Facebook Campaign data that was inserted.

#### - saveFacebookCampaignsActive

##### Parameters

- `facebookCampaignData`: Array With Facebook Campaign Data With Active Property.

##### Return

A list of Facebook Campaign data that was inserted.

#### - listFacebookCampaigns

##### Parameters

- This method has not parameter

##### Return

A list of objects with Facebook Campaign data.

#### - listFacebookCampaignById

##### Parameters

- `facebookCampaignId`: Facebook Campaign Id.

##### Return

An object with Facebook Campaign data filtered by id.

#### - listActiveFacebookCampaignByShopifyProductId

##### Parameters

- `shopifyProductId`: Shopify Product Id.

##### Return

An object with Facebook Campaign data filtered by Shopify Product id.

#### - listFacebookCampaignByFacebookAdAccountId

##### Parameters

- `facebookAdAccountId`: Facebook Ad Account Id.

##### Return

An object with Facebook Campaign data filtered by facebook ad account id.

#### - listActiveFacebookCampaignByFacebookAdAccountId

##### Parameters

- `facebookAdAccountId`: Object With Facebook Ad Account Id.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

An object with Facebook Campaign data filtered by facebook ad account id.

#### - updateFacebookCampaignById

##### Parameters

- `facebookCampaignId`: Object With Facebook Campaign Id.
- `facebookCampaignData`: Object With Facebook Campaign Data.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

An object with Facebook Campaign data updated.

#### - deleteFacebookCampaignsByDashboardUser

##### Parameters

- `dashboardUserId`: Object With Dashboard User Id.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

A list of Facebook Campaign data deleted.

### Facebook Campaign Insight - Functions

---

#### - saveFacebookCampaignInsight

##### Parameters

- `facebookCampaignInsightData`: Facebook Campaign Insight Data.

##### Return

An object with Facebook Campaign Insight data.

#### - listFacebookCampaignsInsightByInsightDate

##### Parameters

- `shopifyProductId`: Object With Shopify Product Id.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

A list of Facebook Campaigns Insight filtered by Shopify Product id and today date.

#### - listFacebookCampaignInsightByInsightDate

##### Parameters

- `facebookCampaignId`: Object With Facebook Campaign Id.
- `todayDate`: Object With Today Date.
- `tz`: Object With Shopify Store Timezone.

##### Return

A list of Facebook Campaigns Insight filtered by insight date, Facebook Campaign id and today date.

#### - updateFacebookAdAccountInsightById

##### Parameters

- `facebookCampaignInsightId`: Facebook Campaign Insight Id.
- `facebookCampaignInsightData`: Facebook Campaign Insight Data.

##### Return

An object with Facebook Campaign Insight data updated.

## Migration

To generate new migration use:

```bash
  yarn migration:create --name=test
```

To apply migrations to a database use (environment vars):

```bash
 yarn run db:migrate
```

To drop all migrations in database use:

```bash
 yarn run db:migrate:undo:all
```

## Seed

To generate new seed use:

```bash
  yarn seed:create --name=test
```

To apply seeds to a database use (environment vars):

```bash
 yarn run db:seed
```

To revert all seed in database use:

```bash
 yarn run db:seed:undo
```

## Tests

To execute all tests use:

```bash
 yarn test
```

## License

© 2019 PROFITFY.ME ALL RIGHTS RESERVED
