Class: Fastlane::Actions::LinearApiAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/linear_api/actions/linear_api_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



25
26
27
# File 'lib/fastlane/plugin/linear_api/actions/linear_api_action.rb', line 25

def self.authors
  ["vnicius"]
end

.available_optionsObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fastlane/plugin/linear_api/actions/linear_api_action.rb', line 38

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :api_key,
                            env_name: "LINEAR_API_KEY",
                         description: "Your personal auth key to access the API",
                            optional: false,
                                type: String),
    
    FastlaneCore::ConfigItem.new(key: :query,
                            env_name: "LINEAR_API_QUERY",
                         description: "The GraphQL query to the api (without 'query')",
                            optional: false,
                                type: String)                                      
  ]
end

.descriptionObject



21
22
23
# File 'lib/fastlane/plugin/linear_api/actions/linear_api_action.rb', line 21

def self.description
  "Provide an interface to access the Linear API"
end

.detailsObject



33
34
35
36
# File 'lib/fastlane/plugin/linear_api/actions/linear_api_action.rb', line 33

def self.details
  # Optional:
  "This plugin will send your query to the Linear - Issue Tracking GraphQL API and return the result json"
end

.example_codeObject



62
63
64
# File 'lib/fastlane/plugin/linear_api/actions/linear_api_action.rb', line 62

def self.example_code
  
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
57
58
59
60
# File 'lib/fastlane/plugin/linear_api/actions/linear_api_action.rb', line 54

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



29
30
31
# File 'lib/fastlane/plugin/linear_api/actions/linear_api_action.rb', line 29

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fastlane/plugin/linear_api/actions/linear_api_action.rb', line 8

def self.run(params)
  parsed_query = params[:query].gsub(/\s+/, " ").gsub(/\"/, "\\\"").strip()

  response = Faraday.post('https://api.linear.app/graphql', 
    '{ "query": "%s" }' % [parsed_query], 
    { 
      'Content-Type' => 'application/json', 
      'Authorization' => params[:api_key] 
    }
  )
  return JSON.parse(response.body)["data"]
end