{"action":"created","comment":{"url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/pulls/comments/41196027","id":41196027,"diff_hunk":"@@ -0,0 +1,125 @@\n+require \"forwardable\"\n+require \"time\"\n+require \"totvs/password_vault/parsers/json_parser\"\n+\n+module Totvs\n+  module PasswordVault\n+    class Base\n+      class Error < StandardError; end\n+      class RequiredParameter < Error; end\n+\n+      extend Forwardable\n+      include JsonParser\n+\n+      def_delegators :connection, :get, :post, :delete\n+\n+      # @!attribute [w] connection\n+      #   @return [Connection]\n+      attr_writer :connection\n+\n+      def initialize(connection: nil)\n+        @connection = connection\n+      end\n+\n+      def connection\n+        @connection ||= Connection.new\n+      end\n+\n+      # @param id [String] the id key to fetch info from\n+      # @return [Hash<Symbol, String>] content the saved content\n+      # @raise [Totvs::PasswordVault::Connection::RequestFailure] if the request was not a success\n+      def retrieve(id:)\n+        headers = { \"Accept\" => \"application/json\" }\n+        response = get(path: build_path(id), headers: headers)\n+        response = parse_json response.body\n+\n+        result = {}\n+        response[translated_group].each do |key, value|\n+          result[(field_key(key) || key).to_sym] = value\n+        end\n+\n+        result\n+      end\n+\n+      # @param id [String] the id key to save info\n+      # @param kwargs [Hash]\n+      def save(id:, **kwargs)\n+        headers = {\n+          \"Accept\" => \"application/json\",\n+          \"Content-Type\" => \"application/json\"\n+        }\n+        validate_params!(kwargs)\n+\n+        post path: build_path(id), body: save_body(kwargs), headers: headers\n+      end\n+\n+      def save_body(params)\n+        body = {}\n+        params.each do |key, value|\n+          body[field_translation(key.to_s).to_sym] = prepare_value_be_post(value) if field_translation(key.to_s)\n+        end\n+        body.delete_if { |_, value| value.nil? || value.empty? }\n+      end\n+\n+      # treat some type of value objects\n+      # @param value [Object] to be prepared\n+      # @return value with some kind of treatment\n+      def prepare_value_be_post(value)\n+        case value\n+        when Array\n+          value.join(\", \")\n+        when Time\n+          value.iso8601\n+        when Hash\n+          value.to_json\n+        else\n+          value\n+        end\n+      end\n+\n+      # @param id [String] the id key to be removed\n+      # @raise [Totvs::PasswordVault::Connection::RequestFailure] if the request was not a success\n+      def destroy(id:)\n+        headers = { \"Accept\" => \"application/json\" }\n+        delete path: build_path(id), headers: headers\n+      end\n+\n+      # validate presence of all required params\n+      def validate_params!(options)","path":"lib/totvs/password_vault/base.rb","position":88,"original_position":88,"commit_id":"ab59f40dc13cbff438286a85fd7416c4d3c0830b","original_commit_id":"2be54762d2d655a2c3e82a4a19be56aa0c238111","user":{"login":"mpelos","id":211458,"avatar_url":"https://avatars.githubusercontent.com/u/211458?v=3","gravatar_id":"","url":"https://api.github.com/users/mpelos","html_url":"https://github.com/mpelos","followers_url":"https://api.github.com/users/mpelos/followers","following_url":"https://api.github.com/users/mpelos/following{/other_user}","gists_url":"https://api.github.com/users/mpelos/gists{/gist_id}","starred_url":"https://api.github.com/users/mpelos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpelos/subscriptions","organizations_url":"https://api.github.com/users/mpelos/orgs","repos_url":"https://api.github.com/users/mpelos/repos","events_url":"https://api.github.com/users/mpelos/events{/privacy}","received_events_url":"https://api.github.com/users/mpelos/received_events","type":"User","site_admin":false},"body":"Na minha opinião, daqui para baixo deveria ser tudo protected =P","created_at":"2015-10-05T20:52:15Z","updated_at":"2015-10-05T20:52:15Z","html_url":"https://github.com/diegoaltheman/totvs_password_vault/pull/1#discussion_r41196027","pull_request_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/pulls/comments/41196027"},"html":{"href":"https://github.com/diegoaltheman/totvs_password_vault/pull/1#discussion_r41196027"},"pull_request":{"href":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/pulls/1","id":46830332,"html_url":"https://github.com/diegoaltheman/totvs_password_vault/pull/1","diff_url":"https://github.com/diegoaltheman/totvs_password_vault/pull/1.diff","patch_url":"https://github.com/diegoaltheman/totvs_password_vault/pull/1.patch","issue_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/issues/1","number":1,"state":"open","locked":false,"title":"TC-2582 - Adiciona api de password e refatora classes","user":{"login":"lthomaz","id":28522,"avatar_url":"https://avatars.githubusercontent.com/u/28522?v=3","gravatar_id":"","url":"https://api.github.com/users/lthomaz","html_url":"https://github.com/lthomaz","followers_url":"https://api.github.com/users/lthomaz/followers","following_url":"https://api.github.com/users/lthomaz/following{/other_user}","gists_url":"https://api.github.com/users/lthomaz/gists{/gist_id}","starred_url":"https://api.github.com/users/lthomaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lthomaz/subscriptions","organizations_url":"https://api.github.com/users/lthomaz/orgs","repos_url":"https://api.github.com/users/lthomaz/repos","events_url":"https://api.github.com/users/lthomaz/events{/privacy}","received_events_url":"https://api.github.com/users/lthomaz/received_events","type":"User","site_admin":false},"body":"Adiciona a API de password refatorando também as classes de Key e Information.","created_at":"2015-10-05T20:37:45Z","updated_at":"2015-10-05T20:52:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4722c0ea22eba70aa00d2ba848c0964087e94f16","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/pulls/1/commits","review_comments_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/pulls/1/comments","review_comment_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/pulls/comments{/number}","comments_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/issues/1/comments","statuses_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/statuses/ab59f40dc13cbff438286a85fd7416c4d3c0830b","head":{"label":"diegoaltheman:TC-2582-password-api","ref":"TC-2582-password-api","sha":"ab59f40dc13cbff438286a85fd7416c4d3c0830b","user":{"login":"diegoaltheman","id":2971456,"avatar_url":"https://avatars.githubusercontent.com/u/2971456?v=3","gravatar_id":"","url":"https://api.github.com/users/diegoaltheman","html_url":"https://github.com/diegoaltheman","followers_url":"https://api.github.com/users/diegoaltheman/followers","following_url":"https://api.github.com/users/diegoaltheman/following{/other_user}","gists_url":"https://api.github.com/users/diegoaltheman/gists{/gist_id}","starred_url":"https://api.github.com/users/diegoaltheman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diegoaltheman/subscriptions","organizations_url":"https://api.github.com/users/diegoaltheman/orgs","repos_url":"https://api.github.com/users/diegoaltheman/repos","events_url":"https://api.github.com/users/diegoaltheman/events{/privacy}","received_events_url":"https://api.github.com/users/diegoaltheman/received_events","type":"User","site_admin":false},"repo":{"id":38324853,"name":"totvs_password_vault","full_name":"diegoaltheman/totvs_password_vault","owner":{"login":"diegoaltheman","id":2971456,"avatar_url":"https://avatars.githubusercontent.com/u/2971456?v=3","gravatar_id":"","url":"https://api.github.com/users/diegoaltheman","html_url":"https://github.com/diegoaltheman","followers_url":"https://api.github.com/users/diegoaltheman/followers","following_url":"https://api.github.com/users/diegoaltheman/following{/other_user}","gists_url":"https://api.github.com/users/diegoaltheman/gists{/gist_id}","starred_url":"https://api.github.com/users/diegoaltheman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diegoaltheman/subscriptions","organizations_url":"https://api.github.com/users/diegoaltheman/orgs","repos_url":"https://api.github.com/users/diegoaltheman/repos","events_url":"https://api.github.com/users/diegoaltheman/events{/privacy}","received_events_url":"https://api.github.com/users/diegoaltheman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/diegoaltheman/totvs_password_vault","description":"","fork":false,"url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault","forks_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/forks","keys_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/keys{/key_id}","collaborators_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/teams","hooks_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/hooks","issue_events_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/issues/events{/number}","events_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/events","assignees_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/assignees{/user}","branches_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/branches{/branch}","tags_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/tags","blobs_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/git/refs{/sha}","trees_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/git/trees{/sha}","statuses_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/statuses/{sha}","languages_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/languages","stargazers_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/stargazers","contributors_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/contributors","subscribers_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/subscribers","subscription_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/subscription","commits_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/commits{/sha}","git_commits_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/git/commits{/sha}","comments_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/comments{/number}","issue_comment_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/issues/comments{/number}","contents_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/contents/{+path}","compare_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/compare/{base}...{head}","merges_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/merges","archive_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/downloads","issues_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/issues{/number}","pulls_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/pulls{/number}","milestones_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/milestones{/number}","notifications_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/labels{/name}","releases_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/releases{/id}","created_at":"2015-06-30T18:05:05Z","updated_at":"2015-06-30T18:32:24Z","pushed_at":"2015-10-05T20:41:51Z","git_url":"git://github.com/diegoaltheman/totvs_password_vault.git","ssh_url":"git@github.com:diegoaltheman/totvs_password_vault.git","clone_url":"https://github.com/diegoaltheman/totvs_password_vault.git","svn_url":"https://github.com/diegoaltheman/totvs_password_vault","homepage":null,"size":180,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"diegoaltheman:master","ref":"master","sha":"791fc3acbbaecef4a0138cafefaa8c8721bb59b5","user":{"login":"diegoaltheman","id":2971456,"avatar_url":"https://avatars.githubusercontent.com/u/2971456?v=3","gravatar_id":"","url":"https://api.github.com/users/diegoaltheman","html_url":"https://github.com/diegoaltheman","followers_url":"https://api.github.com/users/diegoaltheman/followers","following_url":"https://api.github.com/users/diegoaltheman/following{/other_user}","gists_url":"https://api.github.com/users/diegoaltheman/gists{/gist_id}","starred_url":"https://api.github.com/users/diegoaltheman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diegoaltheman/subscriptions","organizations_url":"https://api.github.com/users/diegoaltheman/orgs","repos_url":"https://api.github.com/users/diegoaltheman/repos","events_url":"https://api.github.com/users/diegoaltheman/events{/privacy}","received_events_url":"https://api.github.com/users/diegoaltheman/received_events","type":"User","site_admin":false},"repo":{"id":38324853,"name":"totvs_password_vault","full_name":"diegoaltheman/totvs_password_vault","owner":{"login":"diegoaltheman","id":2971456,"avatar_url":"https://avatars.githubusercontent.com/u/2971456?v=3","gravatar_id":"","url":"https://api.github.com/users/diegoaltheman","html_url":"https://github.com/diegoaltheman","followers_url":"https://api.github.com/users/diegoaltheman/followers","following_url":"https://api.github.com/users/diegoaltheman/following{/other_user}","gists_url":"https://api.github.com/users/diegoaltheman/gists{/gist_id}","starred_url":"https://api.github.com/users/diegoaltheman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diegoaltheman/subscriptions","organizations_url":"https://api.github.com/users/diegoaltheman/orgs","repos_url":"https://api.github.com/users/diegoaltheman/repos","events_url":"https://api.github.com/users/diegoaltheman/events{/privacy}","received_events_url":"https://api.github.com/users/diegoaltheman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/diegoaltheman/totvs_password_vault","description":"","fork":false,"url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault","forks_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/forks","keys_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/keys{/key_id}","collaborators_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/teams","hooks_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/hooks","issue_events_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/issues/events{/number}","events_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/events","assignees_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/assignees{/user}","branches_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/branches{/branch}","tags_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/tags","blobs_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/git/refs{/sha}","trees_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/git/trees{/sha}","statuses_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/statuses/{sha}","languages_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/languages","stargazers_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/stargazers","contributors_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/contributors","subscribers_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/subscribers","subscription_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/subscription","commits_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/commits{/sha}","git_commits_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/git/commits{/sha}","comments_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/comments{/number}","issue_comment_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/issues/comments{/number}","contents_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/contents/{+path}","compare_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/compare/{base}...{head}","merges_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/merges","archive_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/downloads","issues_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/issues{/number}","pulls_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/pulls{/number}","milestones_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/milestones{/number}","notifications_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/labels{/name}","releases_url":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/releases{/id}","created_at":"2015-06-30T18:05:05Z","updated_at":"2015-06-30T18:32:24Z","pushed_at":"2015-10-05T20:41:51Z","git_url":"git://github.com/diegoaltheman/totvs_password_vault.git","ssh_url":"git@github.com:diegoaltheman/totvs_password_vault.git","clone_url":"https://github.com/diegoaltheman/totvs_password_vault.git","svn_url":"https://github.com/diegoaltheman/totvs_password_vault","homepage":null,"size":180,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/pulls/1"},"html":{"href":"https://github.com/diegoaltheman/totvs_password_vault/pull/1"},"issue":{"href":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/issues/1"},"comments":{"href":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/diegoaltheman/totvs_password_vault/statuses/ab59f40dc13cbff438286a85fd7416c4d3c0830b"}}}}