Class: SuperGood::SolidusTaxjar::CachedApi

Inherits:
Object
  • Object
show all
Defined in:
lib/super_good/solidus_taxjar/cached_api.rb

Instance Method Summary collapse

Constructor Details

#initialize(api: SuperGood::SolidusTaxjar.api) ⇒ CachedApi

Returns a new instance of CachedApi.

Parameters:



5
6
7
# File 'lib/super_good/solidus_taxjar/cached_api.rb', line 5

def initialize(api: SuperGood::SolidusTaxjar.api)
  @api = api
end

Instance Method Details

#nexus_regions(refresh: false) ⇒ Object

Parameters:

  • refresh (Boolean) (defaults to: false)

    forces a refresh of the cached regions



10
11
12
13
14
15
16
# File 'lib/super_good/solidus_taxjar/cached_api.rb', line 10

def nexus_regions(refresh: false)
  Rails.cache.fetch(
    :nexus_regions,
    expires_in: SuperGood::SolidusTaxjar.cache_duration,
    force: refresh
  ) { api.nexus_regions }
end