Sha256: cbc0acd2096e51398f1161c67c14822cfaf7f908b4590b13bcf267823a2d0131
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true require 'httparty' module VixenRename # Interact with a VixenGroup API # # Example: # VixenRename::Net.new.get_video_by_id 100415, 'VIXEN' class Net include HTTParty base_uri "https://www.vixen.com" # @param [Integer] video_id # @param [String] site # @return [Hash] def get_video_by_id(video_id, site) @video_id = video_id @site = site resp = self.class.post("/graphql", body: body, headers: headers) raise VixenAPIError, resp.code, resp.parsed_response, "HTTP Failed" if resp.code != 200 { video_id: resp.dig("data", "findOneVideo", "videoId").to_i, title: resp.dig("data", "findOneVideo", "title"), release_date: Time.parse(resp.dig("data", "findOneVideo", "releaseDate")), models: resp.dig("data", "findOneVideo", "modelsSlugged").map { |m| m["name"] }, site: site } end private # Generate the POST body # # @return [JSON] def body { "operationName": "getVideo", "variables": { "videoId": @video_id, "site": @site }, "query": "query getVideo($videoId: ID, $site: Site) { findOneVideo(input: { videoId: $videoId, site: $site })" \ "{id: uuid videoId title releaseDate modelsSlugged: models{name}}}" }.to_json end # @return [Hash{Symbol->String (frozen)}] headers def headers { "content-type": "application/json" } end end end # VixenRename::Net.new.get_video_by_id 100415, 'VIXEN'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vixen_rename-0.1.0 | lib/vixen_rename/net.rb |