Class: Activewave

Inherits:
Object
  • Object
show all
Defined in:
lib/activewave.rb

Constant Summary collapse

LIST_ALL_PRODUCTS_QUERY =
%{
  business(id: "#{@business_id}") {
   id
   products(page: 1, pageSize: 100) {
     pageInfo {
       currentPage
       totalPages
       totalCount
     }
     edges {
       node {
         id
         name
         description
         unitPrice
         defaultSalesTaxes {
           id
           name
           abbreviation
           rate
         }
         isSold
         isBought
         isArchived
         createdAt
         modifiedAt
       }
     }
   }
 }
}
LIST_CUSTOMERS_QUERY =
%{
  business(id: "#{@business_id}") {
   id
   customers(page: 1, pageSize: 100, sort: [NAME_ASC]) {
     pageInfo {
       currentPage
       totalPages
       totalCount
     }
     edges {
       node {
         id
         name
         email
       }
     }
   }
 }
}
LIST_ALL_INVOICES_QUERY =
%{
  business(id: "#{@business_id}") {
   id
   isClassicInvoicing
   invoices(page: 0, pageSize: 100) {
     pageInfo {
       currentPage
       totalPages
       totalCount
     }
     edges {
       node {
         id
         createdAt
         modifiedAt
         pdfUrl
         viewUrl
         status
         title
         subhead
         invoiceNumber
         invoiceDate
         poNumber
         customer {
           id
           name
           # Can add additional customer fields here
         }
         currency {
           code
         }
         dueDate
         amountDue {
           value
           currency {
             symbol
           }
         }
         amountPaid {
           value
           currency {
             symbol
           }
         }
         taxTotal {
           value
           currency {
             symbol
           }
         }
         total {
           value
           currency {
             symbol
           }
         }
         exchangeRate
         footer
         memo
         disableCreditCardPayments
         disableBankPayments
         itemTitle
         unitTitle
         priceTitle
         amountTitle
         hideName
         hideDescription
         hideUnit
         hidePrice
         hideAmount
         items {
           product {
             id
             name
             # Can add additional product fields here
           }
           description
           quantity
           price
           subtotal {
             value
             currency {
               symbol
             }
           }
           total {
             value
             currency {
               symbol
             }
           }
           account {
             id
             name
             subtype {
               name
               value
             }
             # Can add additional account fields here
           }
           taxes {
             amount {
               value
             }
             salesTax {
               id
               name
               # Can add additional sales tax fields here
             }
           }
         }
         lastSentAt
         lastSentVia
         lastViewedAt
       }
     }
   }
 }
}
LIST_BUSINESSES =
%{
    businesses(page: 1, pageSize: 10) {
    pageInfo {
      currentPage
      totalPages
      totalCount
    }
    edges {
      node {
        id
        name
        isClassicAccounting
        isClassicInvoicing
        isPersonal
      }
    }
  }
}
LIST_USERS =
%{
  user {
    id
    defaultEmail
  }
}
@@wave_api_url =
"https://gql.waveapps.com/graphql/public"
@@https =
Net::HTTP.new(url.host, url.port)
@@request =
Net::HTTP::Post.new(url)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(business_id, api_token) ⇒ Activewave



10
11
12
13
14
# File 'lib/activewave.rb', line 10

def initialize(business_id, api_token)
  @business_id = business_id
  @api_token   = api_token

end

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



8
9
10
# File 'lib/activewave.rb', line 8

def api_token
  @api_token
end

#business_idObject

Returns the value of attribute business_id.



8
9
10
# File 'lib/activewave.rb', line 8

def business_id
  @business_id
end

Instance Method Details

#create_customer(name, first_name, last_name, email = nil) ⇒ Object



224
225
226
# File 'lib/activewave.rb', line 224

def create_customer(name, first_name, last_name, email=nil)
  create_a_customer(name, first_name, last_name, email)
end

#create_expense_record(date, anchor_account_id, line_item_account_id, amount, desc) ⇒ Object



237
238
239
# File 'lib/activewave.rb', line 237

def create_expense_record(date, , , amount, desc)
  create_a_transaction(date, , , amount, desc, "EXPENSES")
end

#create_invoice(driver_id, product_id, status = "SAVED") ⇒ Object



228
229
230
# File 'lib/activewave.rb', line 228

def create_invoice(driver_id, product_id, status="SAVED")
  create_an_invoice(driver_id, product_id, status)
end

#create_sales_record(date, anchor_account_id, line_item_account_id, amount, desc) ⇒ Object



233
234
235
# File 'lib/activewave.rb', line 233

def create_sales_record(date, , , amount, desc)
  create_a_transaction(date, , , amount, desc)
end

#current_userObject



245
246
247
# File 'lib/activewave.rb', line 245

def current_user
  execute(LIST_USERS)
end

#get_current_userObject



253
254
255
# File 'lib/activewave.rb', line 253

def get_current_user
  execute(LIST_USERS)
end

#get_user_detailsObject



249
250
251
# File 'lib/activewave.rb', line 249

def get_user_details
  execute(LIST_USERS)
end

#list_all_assetsObject



277
278
279
# File 'lib/activewave.rb', line 277

def list_all_assets
  list_assets_or_liabilities()
end

#list_all_businessesObject



273
274
275
# File 'lib/activewave.rb', line 273

def list_all_businesses
  execute(LIST_BUSINESSES)
end

#list_all_customersObject



265
266
267
# File 'lib/activewave.rb', line 265

def list_all_customers
  execute(LIST_CUSTOMERS_QUERY)
end

#list_all_expensesObject



293
294
295
# File 'lib/activewave.rb', line 293

def list_all_expenses
  list_assets_or_liabilities("EXPENSE")
end

#list_all_incomeObject



285
286
287
# File 'lib/activewave.rb', line 285

def list_all_income
  list_assets_or_liabilities("INCOME")
end

#list_all_incomesObject



281
282
283
# File 'lib/activewave.rb', line 281

def list_all_incomes
  list_assets_or_liabilities("INCOME")
end

#list_all_invoicesObject



269
270
271
# File 'lib/activewave.rb', line 269

def list_all_invoices
  execute(LIST_ALL_INVOICES_QUERY)
end

#list_all_productsObject



261
262
263
# File 'lib/activewave.rb', line 261

def list_all_products
  execute(LIST_ALL_PRODUCTS_QUERY)
end

#list_incomesObject



289
290
291
# File 'lib/activewave.rb', line 289

def list_incomes
  list_assets_or_liabilities("INCOME")
end

#list_usersObject



241
242
243
# File 'lib/activewave.rb', line 241

def list_users
  execute(LIST_USERS)
end

#userObject



257
258
259
# File 'lib/activewave.rb', line 257

def user
  execute(LIST_USERS)
end