lockstep_rails 0.3.63 → 0.3.65

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c66de5c8265c8bf92d2d07b205a0a9de6340f00105ce5e6110cbc5002e73f0c
4
- data.tar.gz: 7a190529d4a770714f9708aa3305c3eda6c23f92a1f80ce71eb6186f8cc2e6c6
3
+ metadata.gz: ffc2c21371e280e4b0d300d21a889b1e9604ea20868527c470cdd21858fe8c05
4
+ data.tar.gz: 2d3f226fe569acb51bf9b9ceddd2eb22c7f7ebaa3ba7e5f8d15ef78043d6c28f
5
5
  SHA512:
6
- metadata.gz: 84608aaf9a7aebf1946f49b9e85dcced53535ad6832f0c0d3f610f255bdf6a016110dff2b78107b6b18d99734b8c968ce4ddc58b89e39ffa7312d4718100e142
7
- data.tar.gz: 9553d0c197a324d3bf7980b518d42264cc4e9533867ee1847b60148612e315965401b637896c3751422ca7b9db358dccd31404646822b4a87608768b1175ba94
6
+ metadata.gz: '018b416e5c30156f70cc03d864ff72d112439d4aa552e174e59f8e414b3fc36a6a0809c2ff4c447c2b7b382361d3d3bcb0cfc763c2080f3dec1e2ae28d5829ee'
7
+ data.tar.gz: 6b3cb5bf9430de1269912ebbac07387f25e46806b9cc62ab6a539783a305049f8dfd9ee2513dc0d71a4edf5d55a406fd4c811579c47173fb6d88eed65e3b3894
data/README.md CHANGED
@@ -166,6 +166,14 @@ if you wish, you can always write raw [Searchlight](https://developer.lockstep.i
166
166
  Lockstep::Connection.where("isActive is true OR default_currency_code in ('USD', 'INR')").execute
167
167
  ```
168
168
 
169
+ ### Destroy and Destroy all
170
+ You can destroy a single object by calling destroy method on one object
171
+ Lockstep::Connection.find(company_id: "17544da8-7be8-4ee2-8c62-cbd81428c68b").destroy
172
+
173
+ You can also destroy multiple objects at once by calling it on the model class and passing an array of relevant ids
174
+
175
+ Lockstep::Connection.destroy_all(id: ["17544da8-7be8-4ee2-8c62-cbd81428c68b"])
176
+
169
177
  ### Count
170
178
  You can fetch the count of available records by calling `count`
171
179
 
@@ -572,13 +572,6 @@ module Lockstep
572
572
  obj
573
573
  end
574
574
 
575
- # Replaced with a batch destroy_all method.
576
- # def self.destroy_all(all)
577
- # all.each do |object|
578
- # object.destroy
579
- # end
580
- # end
581
-
582
575
  def self.class_attributes
583
576
  @class_attributes ||= {}
584
577
  end
@@ -822,6 +815,18 @@ module Lockstep
822
815
  false
823
816
  end
824
817
 
818
+ def self.destroy_all(id: [])
819
+ id.each_slice(100) do |sliced_ids|
820
+ resp = resource.delete('', body: { 'idsToDelete' => sliced_ids })
821
+ return false unless resp.code.to_s == '200'
822
+ # TODO: Since this could fail for certain IDs return deleted_ids in batch
823
+ end
824
+
825
+ @attributes = {}
826
+ @unsaved_attributes = {}
827
+ return true
828
+ end
829
+
825
830
  def reload
826
831
  return false if new?
827
832
 
@@ -159,8 +159,8 @@ module Lockstep
159
159
  request(:put, path, body, params)
160
160
  end
161
161
 
162
- def delete(path)
163
- request(:delete, path, {}, {})
162
+ def delete(path, body: {})
163
+ request(:delete, path, body, {})
164
164
  end
165
165
 
166
166
  def post_magic_link(path, body: {}, params: {})
@@ -2,6 +2,21 @@ class Lockstep::Payment < Lockstep::ApiRecord
2
2
  self.model_name_uri = "v1/Payments"
3
3
  self.id_ref = "payment_id"
4
4
  load_schema(Schema::Payment)
5
-
5
+ ERP_WRITE = "erp_write"
6
+ ERP_WRITE_PATH_PARAMS = "erp-write"
6
7
  belongs_to :connection, class_name: "Lockstep::Connection", foreign_key: :company_id
8
+
9
+ # Overriding create to support erp-write in path params
10
+ def create
11
+ if attributes_for_saving.key?(ERP_WRITE)
12
+ attributes_for_saving.delete(ERP_WRITE)
13
+ attrs = attributes_for_saving.transform_keys { |key| key.camelize(:lower) }
14
+ resp = resource.post(ERP_WRITE_PATH_PARAMS, body: attrs)
15
+ result = post_result(resp)
16
+ else
17
+ attrs = attributes_for_saving.transform_keys { |key| key.camelize(:lower) }
18
+ resp = resource.post('', body: [attrs])
19
+ result = post_result(resp)
20
+ end
21
+ end
7
22
  end
@@ -1,3 +1,3 @@
1
1
  module LockstepRails
2
- VERSION = '0.3.63'
2
+ VERSION = '0.3.65'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockstep_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.63
4
+ version: 0.3.65
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vivek AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-01 00:00:00.000000000 Z
11
+ date: 2023-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails