Module: MultiVideoStreaming

Defined in:
lib/multi_video_streaming.rb,
lib/multi_video_streaming/version.rb,
lib/multi_video_streaming/response.rb,
lib/multi_video_streaming/drivers/s3.rb,
lib/multi_video_streaming/drivers/bunny.rb,
lib/multi_video_streaming/drivers/vimeo.rb,
lib/multi_video_streaming/services/https.rb,
lib/multi_video_streaming/factories/drive.rb,
lib/multi_video_streaming/protocols/https.rb,
lib/multi_video_streaming/platforms_support.rb,
lib/multi_video_streaming/protocols/platform.rb,
lib/multi_video_streaming/protocols/interface.rb,
lib/multi_video_streaming/errors/missing_param.rb,
lib/multi_video_streaming/errors/invalid_platform_name.rb,
lib/multi_video_streaming/errors/invalid_s3_method_name.rb,
lib/multi_video_streaming/utils/s3/generate_presign_url.rb,
lib/multi_video_streaming/errors/invalid_platforms_param.rb,
lib/multi_video_streaming/errors/duplicated_platform_name.rb,
lib/multi_video_streaming/errors/s3_is_not_valid_to_upload.rb,
lib/multi_video_streaming/utils/s3/create_multipart_upload.rb,
lib/multi_video_streaming/helpers/get_default_error_message.rb,
lib/multi_video_streaming/helpers/sort_files_array_by_label.rb,
lib/multi_video_streaming/utils/s3/complete_multipart_upload.rb,
lib/multi_video_streaming/utils/s3/generate_presign_part_url.rb,
lib/multi_video_streaming/validators/platform_name_validator.rb,
lib/multi_video_streaming/validators/platforms_hash_validator.rb,
lib/multi_video_streaming/validators/platforms_array_validator.rb,
lib/multi_video_streaming/validators/required_fields_validator.rb,
lib/multi_video_streaming/validators/platforms_position_validator.rb

Defined Under Namespace

Modules: Drivers, Errors, Factories, Helpers, Protocols, Services, Utils, Validators Classes: DriverResponse, FinalResponse, Response

Constant Summary collapse

VERSION =
"1.1.0"
PLATFORMS_SUPPORT =
["vimeo", "bunny", "s3"]

Class Method Summary collapse

Class Method Details

.delete(*platforms) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/multi_video_streaming.rb', line 75

def self.delete(*platforms)
  MultiVideoStreaming::Validators::PlatformsArrayValidator.validate(platforms_array: platforms)
  MultiVideoStreaming::Validators::PlatformsHashValidator.validate(platforms_hash: platforms, method: :get, number_of_platforms: platforms.length)

  response_instance = MultiVideoStreaming::Response.new
  required_fields_validator_instance = MultiVideoStreaming::Validators::RequiredFieldsValidator
  https_service_instance = MultiVideoStreaming::Services::Https.new

  platforms.each do |platform|
    platform_instance = MultiVideoStreaming::Factories::Drive.get_platform_instance(
      platform_name: platform[:platform_name],
      dependency_params: platform[:dependency_params],
      response_instance: response_instance,
      required_fields_validator_instance: required_fields_validator_instance,
      https_service_instance: https_service_instance
    )
    platform_instance.delete_video    
  end
  response_instance.get_all_response
end

.get(*platforms) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/multi_video_streaming.rb', line 47

def self.get(*platforms)
  MultiVideoStreaming::Validators::PlatformsArrayValidator.validate(platforms_array: platforms)
  MultiVideoStreaming::Validators::PlatformsHashValidator.validate(platforms_hash: platforms, method: :get, number_of_platforms: platforms.length)

  response_instance = MultiVideoStreaming::Response.new
  required_fields_validator_instance = MultiVideoStreaming::Validators::RequiredFieldsValidator
  https_service_instance = MultiVideoStreaming::Services::Https.new

  platforms_in_the_correct_order = MultiVideoStreaming::Validators::PlatformsPositionValidator.validate(platforms: platforms)

  platforms_in_the_correct_order.each do |platform|
    platform_instance = MultiVideoStreaming::Factories::Drive.get_platform_instance(
      platform_name: platform[:platform_name],
      dependency_params: platform[:dependency_params],
      response_instance: response_instance,
      required_fields_validator_instance: required_fields_validator_instance,
      https_service_instance: https_service_instance
    )
    platform_response = platform_instance.get_video

    if platform_response == "success"
      return response_instance.get_this_response
    end
  end

  response_instance.get_all_response
end

.upload(url, title, *platforms) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/multi_video_streaming.rb', line 22

def self.upload(url, title, *platforms)
  MultiVideoStreaming::Validators::PlatformsArrayValidator.validate(platforms_array: platforms)
  MultiVideoStreaming::Validators::PlatformsHashValidator.validate(platforms_hash: platforms, method: :create, number_of_platforms: platforms.length)

  response_instance = MultiVideoStreaming::Response.new
  required_fields_validator_instance = MultiVideoStreaming::Validators::RequiredFieldsValidator
  https_service_instance = MultiVideoStreaming::Services::Https.new

  platforms.each do |platform|
    platform_instance = MultiVideoStreaming::Factories::Drive.get_platform_instance(
      platform_name: platform[:platform_name],
      dependency_params: platform[:dependency_params],
      response_instance: response_instance,
      required_fields_validator_instance: required_fields_validator_instance,
      https_service_instance: https_service_instance
    )

    if !platform_instance.is_a?(MultiVideoStreaming::Drivers::S3)
      platform_instance.upload_video(url: url, title: title)
    end
  end

  response_instance.get_all_response
end