Class: CardDB::Rails::DeckSyncService

Inherits:
Object
  • Object
show all
Defined in:
lib/carddb/rails/deck_sync_service.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(external_ref:, input:, client: nil) ⇒ DeckSyncService

Returns a new instance of DeckSyncService.



10
11
12
13
14
# File 'lib/carddb/rails/deck_sync_service.rb', line 10

def initialize(external_ref:, input:, client: nil)
  @external_ref = external_ref
  @input = input
  @client = client || CardDB::Rails.client
end

Class Method Details

.call(external_ref:, input:, client: nil) ⇒ Object



6
7
8
# File 'lib/carddb/rails/deck_sync_service.rb', line 6

def self.call(external_ref:, input:, client: nil)
  new(external_ref: external_ref, input: input, client: client).call
end

Instance Method Details

#callObject



16
17
18
# File 'lib/carddb/rails/deck_sync_service.rb', line 16

def call
  @client.decks.upsert_by_external_ref(input: @input.merge(externalRef: @external_ref))
end