Sha256: e3f68fbf398bd364ce10c027b1ec56b920d39ce98aa91faddfd779a7857c5aa6

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

module Commercelayer
  module CLI
    module Helpers

      def config_data
        YAML::load_file(config_path).deep_symbolize_keys
      end

      def config_data_template
        {
          "commercelayer" => {
            "site" => "https://<subdomain>.commercelayer.io",
            "client_id" => "YOUR-COMMERCELAYER-CLIENT-ID",
            "client_secret" => "YOUR-COMMERCELAYER-CLIENT-SECRET",
            "scope" => "market:<market_id>",
          },
          "dato" => {
            "api_key" => "YOUR-DATOCMS-APIKEY"
          },
          "contentful" => {
            "space" => "YOUR-CONTENTFUL-SPACE-ID",
            "access_token" => "YOUR-CONTENTFUL-ACCESS-TOKEN"
          }
        }.to_yaml
      end

      def config_path
        ENV['HOME'] + "/.commercelayer-cli.yml"
      end

      def commercelayer_client
        Commercelayer::Client.new(
          client_id: config_data[:commercelayer][:client_id],
          client_secret: config_data[:commercelayer][:client_secret],
          scope: config_data[:commercelayer][:scope],
          site: config_data[:commercelayer][:site]
        )
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
commercelayer-cli-0.2.4 lib/commercelayer/cli/helpers.rb
commercelayer-cli-0.2.3 lib/commercelayer/cli/helpers.rb