Sha256: c72ee18e242718331400680f3fe129b8dac5a27aeec086b5d37f87172179b0be

Contents?: true

Size: 1.23 KB

Versions: 16

Compression:

Stored size: 1.23 KB

Contents

require_relative '../../base'
require_relative '../../tunes/tunes_client'

module Spaceship
  module ConnectAPI
    module TestFlight
      class Base < Spaceship::Base
        def self.client
          # Verify there is a client that can be used
          if Spaceship::Tunes.client
            # Initialize new client if new or if team changed
            if @client.nil? || @client.team_id != Spaceship::Tunes.client.team_id
              @client = Client.client_with_authorization_from(Spaceship::Tunes.client)
            end
          end

          # Need to handle not having a client but this shouldn't ever happen
          raise "Please login using `Spaceship::Tunes.login('user', 'password')`" unless @client

          @client
        end

        ##
        # Have subclasses inherit the client from their superclass
        #
        # Essentially, we are making a class-inheritable-accessor as described here:
        # https://apidock.com/rails/v4.2.7/Class/class_attribute
        def self.inherited(subclass)
          this_class = self
          subclass.define_singleton_method(:client) do
            this_class.client
          end
        end

        def to_json
          raw_data.to_json
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fastlane-2.126.0.beta.20190623200100 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190622200100 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190621200104 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190620200055 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190619200046 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190618200051 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190617200114 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190616200045 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190615200013 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190614200105 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190613200017 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190611200027 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190610200032 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190609200013 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190608200023 spaceship/lib/spaceship/connect_api/testflight/base.rb
fastlane-2.126.0.beta.20190607200028 spaceship/lib/spaceship/connect_api/testflight/base.rb