Sha256: 63d7c53ac17095cd14d1f2a6048b293e3b1601b27b7d2fd32e253d429a3a7477

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require_relative '../flow_promised_land_rest'

module FlowNodePatron
  module FlowPromisedLandBoxOperation
    # 去promised_land 拿出队的box info
    def fetch_outqueue_box
      answer = FlowPromisedLandRest.get "/#{specific_org_patrons_url}/fetch_outqueue_box", {}
      return nil if answer.dig(:json, :queue) == 'empty'
      answer
    end

    def get_box_info(box_id)
      FlowPromisedLandRest.get "/#{specific_org_patrons_url}/get_box_info", box_id: box_id
    end

    def closed_box?(box_id)
      answer = get_box_info(box_id)
      answer[:status] == 'closed'
    end

    def delete_box(id)
      FlowPromisedLandRest.post("/#{specific_org_patrons_url}/delete_box", box_id: id)
    end

    # 主要给测试用的函数,平时不要乱用
    def push_a_test_box
      FlowPromisedLandRest.post("/#{specific_org_patrons_url}/push_a_test_box", {})
    end

    def queue_list
      FlowPromisedLandRest.get("/#{specific_org_patrons_url}/queue_box_list")
    end

    private

    def specific_org_patrons_url
      "org_patrons/#{::FlowNodePatron::Config::PROMISED_LAND_ORG_PATRON_TOKEN}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flow_org_patron-0.1.1 lib/flow_node_patron/operations/flow_promised_land_box_operation.rb