business-engineer 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/lib/business-engineer.rb +18 -0
 - data/lib/business-engineer/api/line/notify-client.rb +25 -0
 - data/lib/business-engineer/version.rb +3 -0
 - metadata +45 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: cbf6d1c36365afab6d76ea1545fb49b4910bd3fb0b6b951540ec6201c2a36e91
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 1917207d62882684218415658e03402dff4b5ae30fa3d47390b3008fcb51adfb
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 69f96a4e31bb9d7cabfedfd963286448bb33cb02d813be5067ec17c73adc1f70b41648b4bc391cf5db7f6e864f73f6e669500eb0be2bba66d755bd4487023c22
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 9ff1fcf2769fd61b00c18b472ea7b317986d01ae675bed91043b9ee523705af7fc9be5be995ac423e31aace593f6bc0d2057b7ac5d00806b20df4db6e9b95fac
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "business-engineer/api/line/notify-client"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "business-engineer/version"
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'net/http'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'uri'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module BusinessEngineer
         
     | 
| 
      
 7 
     | 
    
         
            +
              module Api
         
     | 
| 
      
 8 
     | 
    
         
            +
                module Line
         
     | 
| 
      
 9 
     | 
    
         
            +
                  module Notify
         
     | 
| 
      
 10 
     | 
    
         
            +
                    def self.message(token: nil, message: nil)
         
     | 
| 
      
 11 
     | 
    
         
            +
                      client = NotifyClient.new
         
     | 
| 
      
 12 
     | 
    
         
            +
                      client.message(token, message)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    end
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'net/http'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'uri'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'json'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class NotifyClient
         
     | 
| 
      
 6 
     | 
    
         
            +
              class ArgumentError < StandardError; end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              attr_reader :http, :uri
         
     | 
| 
      
 9 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 10 
     | 
    
         
            +
                @uri = URI.parse("https://notify-api.line.me/api/notify")
         
     | 
| 
      
 11 
     | 
    
         
            +
                http = Net::HTTP.new(uri.host, uri.port)
         
     | 
| 
      
 12 
     | 
    
         
            +
                http.use_ssl = true
         
     | 
| 
      
 13 
     | 
    
         
            +
                @http = http
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              def message(token, message)
         
     | 
| 
      
 17 
     | 
    
         
            +
                token ||= ENV['LINE_NOTIFY_TOKEN']
         
     | 
| 
      
 18 
     | 
    
         
            +
                raise ArgumentError if token.nil? || message.nil?
         
     | 
| 
      
 19 
     | 
    
         
            +
                req = Net::HTTP::Post.new uri
         
     | 
| 
      
 20 
     | 
    
         
            +
                req["Authorization"] = "Bearer #{token}"
         
     | 
| 
      
 21 
     | 
    
         
            +
                req.set_form_data(message: message)
         
     | 
| 
      
 22 
     | 
    
         
            +
                res = http.start { |http| http.request req }
         
     | 
| 
      
 23 
     | 
    
         
            +
                JSON.parse(res.body)
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,45 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: business-engineer
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Lawrence.Net
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-09-04 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
      
 13 
     | 
    
         
            +
            description: ruby gem for business engineer
         
     | 
| 
      
 14 
     | 
    
         
            +
            email: arnger@gmail.com
         
     | 
| 
      
 15 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 16 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 17 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 18 
     | 
    
         
            +
            files:
         
     | 
| 
      
 19 
     | 
    
         
            +
            - lib/business-engineer.rb
         
     | 
| 
      
 20 
     | 
    
         
            +
            - lib/business-engineer/api/line/notify-client.rb
         
     | 
| 
      
 21 
     | 
    
         
            +
            - lib/business-engineer/version.rb
         
     | 
| 
      
 22 
     | 
    
         
            +
            homepage: http://rubygems.org/gems/arnger
         
     | 
| 
      
 23 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 24 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 25 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 26 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 27 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 28 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 29 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 30 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 31 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 32 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 33 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 34 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 35 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 36 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 37 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 38 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 39 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 40 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 41 
     | 
    
         
            +
            rubygems_version: 3.0.4
         
     | 
| 
      
 42 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 43 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 44 
     | 
    
         
            +
            summary: ruby gem for business engineer
         
     | 
| 
      
 45 
     | 
    
         
            +
            test_files: []
         
     |