activewave 0.0.1 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/activewave.rb +31 -9
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a6060d056766fe30473be0cf81458cba70ac464b60f1b80ef7d4c3baa760531
4
- data.tar.gz: e0aea8db60e4aa74c36746137fbd9775a2bee331b9434131d66265fa0474a636
3
+ metadata.gz: ce2c85732a665ba3aada17727a4dc13ed45b2176f1ed6438cb1b6e8bffff8af3
4
+ data.tar.gz: 1f0a1bdc21e9a6a4eb58794abc550c44d358a140c538e8912d2f3182aaf4f5d5
5
5
  SHA512:
6
- metadata.gz: 9533d5ce3283b87b61a88b0a3f9d6a626a3d48312d4bd728b6295f2580ebbbbde41ea9b80d25607f9cf31d1202f4c7e29de0a7a4cefc8169a368f12594c90c2c
7
- data.tar.gz: 5191ee9f5e1723687f47a9dfa42689dabc255cb0071ff68d8d0ff466e22468332a633c7c03e9419d5dd2d0497cfff76bb887546d0f7a5910340af6d6f1366a1e
6
+ metadata.gz: 825de6f26c48f1a527f03c8601c19690a65fd39943a00c0d9973d5872c9853fe9321925418c09f471a145fbeb1cc504f878ca5fbaf1401e73ef5790fa1faa4fc
7
+ data.tar.gz: 002054ed5f1f982a372614c4f2611373e945b00a4f019945bd55fab8e6877e24694fb2f44d3b0ba70fd5184d490c8e131a780bf31648a6a20507555455481927
data/lib/activewave.rb CHANGED
@@ -2,14 +2,12 @@ require 'httparty'
2
2
  require 'json'
3
3
  require "uri"
4
4
  require "net/http"
5
- require 'dotenv'
6
- Dotenv.load
7
5
 
8
6
  module ACTIVEWAVE
9
7
 
10
- WAVE_API_URL = ENV['WAVE_API_URL']
11
- BUSINESS_ID = ENV['BUSINESS_ID']
12
- API_TOKEN = ENV['API_TOKEN']
8
+ WAVE_API_URL = "https://gql.waveapps.com/graphql/public"
9
+ BUSINESS_ID = ENV.fetch("#{BUSINESS_ID}")
10
+ API_TOKEN = ENV.fetch("#{API_TOKEN}")
13
11
 
14
12
  url = URI(WAVE_API_URL)
15
13
 
@@ -241,6 +239,22 @@ module ACTIVEWAVE
241
239
  execute(LIST_USERS)
242
240
  end
243
241
 
242
+ def self.current_user
243
+ execute(LIST_USERS)
244
+ end
245
+
246
+ def self.get_user_details
247
+ execute(LIST_USERS)
248
+ end
249
+
250
+ def self.get_current_user
251
+ execute(LIST_USERS)
252
+ end
253
+
254
+ def self.user
255
+ execute(LIST_USERS)
256
+ end
257
+
244
258
  def self.list_all_products
245
259
  execute(LIST_ALL_PRODUCTS_QUERY)
246
260
  end
@@ -265,6 +279,14 @@ module ACTIVEWAVE
265
279
  list_assets_or_liabilities("INCOME")
266
280
  end
267
281
 
282
+ def self.list_all_income
283
+ list_assets_or_liabilities("INCOME")
284
+ end
285
+
286
+ def self.list_incomes
287
+ list_assets_or_liabilities("INCOME")
288
+ end
289
+
268
290
  def self.list_all_expenses
269
291
  list_assets_or_liabilities("EXPENSE")
270
292
  end
@@ -275,27 +297,27 @@ module ACTIVEWAVE
275
297
  current_action = action[type.to_sym]
276
298
  @@request.body = "{\"query\":\" mutation ($input:MoneyTransactionCreateInput!){\\n moneyTransactionCreate(input:$input){\\n didSucceed\\n inputErrors{\\n path\\n message\\n code\\n }\\n transaction{\\n id\\n }\\n }\\n }\",\"variables\":{\"input\":{\"businessId\":\"#{BUSINESS_ID}\",\"externalId\":\"#{desc + Time.now.to_s}\",\"date\":\"#{date}\",\"description\":\"#{desc}\",\"anchor\":{\"accountId\":\"#{anchor_account_id}\",\"amount\":#{amount},\"direction\":\"#{current_action[0]}\"},\"lineItems\":[{\"accountId\":\"#{line_item_account_id}\",\"amount\":#{amount},\"balance\":\"#{current_action[1]}\"}]}}}"
277
299
  response = @@https.request(@@request)
278
- response.read_body
300
+ JSON.parse(response.read_body)
279
301
  end
280
302
 
281
303
  def self.create_an_invoice(driver_id, product_id, status="SAVED")
282
304
  @@request.body = "{\"query\":\"mutation ($input: InvoiceCreateInput!) {\\n invoiceCreate(input: $input) {\\n didSucceed\\n inputErrors {\\n message\\n code\\n path\\n }\\n invoice {\\n id\\n createdAt\\n modifiedAt\\n pdfUrl\\n viewUrl\\n status\\n title\\n subhead\\n invoiceNumber\\n invoiceDate\\n poNumber\\n customer {\\n id\\n name\\n # Can add additional customer fields here\\n }\\n currency {\\n code\\n }\\n dueDate\\n amountDue {\\n value\\n currency {\\n symbol\\n }\\n }\\n amountPaid {\\n value\\n currency {\\n symbol\\n }\\n }\\n taxTotal {\\n value\\n currency {\\n symbol\\n }\\n }\\n total {\\n value\\n currency {\\n symbol\\n }\\n }\\n exchangeRate\\n footer\\n memo\\n disableCreditCardPayments\\n disableBankPayments\\n itemTitle\\n unitTitle\\n priceTitle\\n amountTitle\\n hideName\\n hideDescription\\n hideUnit\\n hidePrice\\n hideAmount\\n items {\\n product {\\n id\\n name\\n # Can add additional product fields here\\n }\\n description\\n quantity\\n price\\n subtotal {\\n value\\n currency {\\n symbol\\n }\\n }\\n total {\\n value\\n currency {\\n symbol\\n }\\n }\\n account {\\n id\\n name\\n subtype {\\n name\\n value\\n }\\n # Can add additional account fields here\\n }\\n taxes {\\n amount {\\n value\\n }\\n salesTax {\\n id\\n name\\n # Can add additional sales tax fields here\\n }\\n }\\n }\\n lastSentAt\\n lastSentVia\\n lastViewedAt\\n }\\n }\\n}\",\"variables\":{\"input\":{\"businessId\":\"#{BUSINESS_ID}\",\"customerId\":\"#{driver_id}\",\"items\":[{\"productId\":\"#{product_id}\"}], \"status\":\"#{status}\"}}}"
283
305
  response = @@https.request(@@request)
284
- response.read_body
306
+ JSON.parse(response.read_body)
285
307
  end
286
308
 
287
309
 
288
310
  def self.create_a_customer(name, first_name, last_name, email)
289
311
  @@request.body = "{\"query\":\"mutation ($input: CustomerCreateInput!) {\\n customerCreate(input: $input) {\\n didSucceed\\n inputErrors {\\n code\\n message\\n path\\n }\\n customer {\\n id\\n name\\n firstName\\n lastName\\n email\\n address {\\n addressLine1\\n addressLine2\\n city\\n province {\\n code\\n name\\n }\\n country {\\n code\\n name\\n }\\n postalCode\\n }\\n currency {\\n code\\n }\\n }\\n }\\n}\",\"variables\":{\"input\":{\"businessId\":\"#{BUSINESS_ID}\",\"name\":\"#{name}\",\"firstName\":\"#{first_name}\",\"lastName\":\"#{last_name}\",\"email\":\"#{email}\",\"currency\":\"GHS\"}}}"
290
312
  response = @@https.request(@@request)
291
- response.read_body
313
+ JSON.parse(response.read_body)
292
314
  end
293
315
 
294
316
 
295
317
  def self.list_assets_or_liabilities(filter="ASSET")
296
318
  @@request.body = "{\"query\":\"query ($businessId: ID!, $page: Int!, $pageSize: Int!) {\\n business(id: $businessId) {\\n id\\n accounts(page: $page, pageSize: $pageSize, types: [#{filter}]) {\\n pageInfo {\\n currentPage\\n totalPages\\n totalCount\\n }\\n edges {\\n node {\\n id\\n name\\n description\\n displayId\\n type {\\n name\\n value\\n }\\n subtype {\\n name\\n value\\n }\\n normalBalanceType\\n isArchived\\n }\\n }\\n }\\n }\\n}\",\"variables\":{\"businessId\":\"#{BUSINESS_ID}\",\"page\":1,\"pageSize\":100}}"
297
319
  response = @@https.request(@@request)
298
- response.read_body
320
+ JSON.parse(response.read_body)
299
321
  end
300
322
 
301
323
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activewave
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - CHARALES OPOKU-AGYEMANG