Sha256: 27f893c8fabd1545d2117353b5e01c1a1ac57d1f5a7f6f05cdade40a2ee97be2

Contents?: true

Size: 1.51 KB

Versions: 16

Compression:

Stored size: 1.51 KB

Contents

module DeployGate
  module API
    module V1
      class Push
        ENDPOINT = "/users/%s/apps"

        class << self

          # @param [String] file_path
          # @param [String] target_user
          # @param [String] token
          # @param [String] message
          # @param [String] distribution_key
          # @param [Boolean] disable_notify
          # @yield Upload process block
          # @return [Hash]
          def upload(file_path, target_user, token, message, distribution_key, disable_notify = false, &process_block)
            res = nil
            open(file_path) do |file|
              res = Base.new(token).post(
                sprintf(ENDPOINT, target_user),
                { :file => file , :message => message, :distribution_key => distribution_key, :disable_notify => disable_notify ? 'yes' : 'no' }) { process_block.call unless process_block.nil? }
            end

            upload_results = {
                :error => res['error'],
                :message => res['because']
            }

            results = res['results']
            unless results.nil?
              upload_results.merge!({
                  :application_name => results['name'],
                  :owner_name => results['user']['name'],
                  :package_name => results['package_name'],
                  :revision => results['revision'],
                  :web_url => Base::BASE_URL + results['path']
              })
            end

            upload_results
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
deploygate-0.5.1 lib/deploygate/api/v1/push.rb
deploygate-0.5.0 lib/deploygate/api/v1/push.rb
deploygate-0.4.1 lib/deploygate/api/v1/push.rb
deploygate-0.4.0 lib/deploygate/api/v1/push.rb
deploygate-0.3.3 lib/deploygate/api/v1/push.rb
deploygate-0.3.2 lib/deploygate/api/v1/push.rb
deploygate-0.3.1 lib/deploygate/api/v1/push.rb
deploygate-0.3.0 lib/deploygate/api/v1/push.rb
deploygate-0.2.3 lib/deploygate/api/v1/push.rb
deploygate-0.2.2 lib/deploygate/api/v1/push.rb
deploygate-0.2.1 lib/deploygate/api/v1/push.rb
deploygate-0.2.0 lib/deploygate/api/v1/push.rb
deploygate-0.1.2 lib/deploygate/api/v1/push.rb
deploygate-0.1.1 lib/deploygate/api/v1/push.rb
deploygate-0.1.0 lib/deploygate/api/v1/push.rb
deploygate-0.0.6 lib/deploygate/api/v1/push.rb